Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Use Placeholders. For SECURITY and (sometimes) for PERFORMANCE

by pg (Canon)
on Nov 14, 2003 at 21:14 UTC ( [id://307216]=note: print w/replies, xml ) Need Help??


in reply to Use Placeholders. For SECURITY and (sometimes) for PERFORMANCE

A very good point, and something that everyone serious about database performance should know.

A prepared statement is the same as a piece of compiled code. At the time you prepare it, it gets compiled and cached. This is much faster than execute a SQL statement on fly.

Have said this, I would like to mention another trick related to "compiled" stuffs in database. Many times, you can improve performance of queries against big tables, by creating a view on top of the table. By doing this, the view get "compiled". Later instead of querying the table, you just query the view.

It sounds like nothing, and only difference is that you moved some of you where clauses from your query statement to the create view statement. But actually there is a big difference, as at the time you create the view, your where clauses get "compiled" as part of the create view statement.

I recently had an application's execution time cut 96%, by creating view, along with other tunings.

Database (or poor database design and tuning) is one of the major performance bottle necks you see from time to time nowadays.

  • Comment on Re: Use Placeholders. For SECURITY and (sometimes) for PERFORMANCE

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://307216]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (None)
    As of 2024-10-15 20:05 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found

      Notices?
      erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.