Jump to content

cache mysql resource

- - - - -

  • Please log in to reply
3 replies to this topic

#1
plb

plb

    Newbie

  • Members
  • PipPip
  • 18 posts
I have to improve performance of some php script written by another programmer; it's quite big and practically impossible to completely understand everything. The good thing is that mysql queries go in one function, so I wonder if it is possible to cache mysql_query($query) resource using memcache.

Thank you in advance.

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
If you don't know where the performance hits are, any optimization is as likely to hurt as help. You really need to do some profiling to localise the problem.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
plb

plb

    Newbie

  • Members
  • PipPip
  • 18 posts
Yes, you are completely right. Here's my idea. There are lots of queries that take some notes that will almost never change, so I want to cache them, but I want to cache mysql query results (resource). Is it possible tectonically?

#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
If these are common queries, mysql is probably already caching the results, saving you the effort. If the mysql database is on the same server as your web server, you won't be gaining anything. If they are on different servers (a good idea), it depends on the size of the data.

Have you checked the algorithmic complexity of your logic yet? Have you looked at the algorithmic complexity of your queries? Have you tried putting logging into your code to tag entrance/exit times to various functions?
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users