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

Re: Re (3): DBI question with placeholders and IN

by htoug (Deacon)
on Oct 01, 2002 at 10:46 UTC ( [id://201965]=note: print w/replies, xml ) Need Help??


in reply to Re (3): DBI question with placeholders and IN
in thread DBI question with placeholders and IN

I would avoid your prepare_cached-execute loop.

The performance of a prepare with repeated executes compared to a repeated prepare-execute is highly driver, database engine and platform dependent. You should carefully test and bendhmark before choosing.

The optimizer that fails over to a tabel scan for an IN clause should be regarded as underpowered. A usefull optimizer should be able to fiund out when it is beneficial to do a tabel sacn and when a repeated series of index/key lookups based on the query. If you areunfortunate enough to be hampered by an optimzer of this kind, then you have to carefully craft your queries to aid the optimizer (and yes, it might be useful to just fetch one value pr execute).

This is one of the main reasons that is it impossible to state anything about performance of queries.

One of the things that irks me most when reading about DBI in the monestary is that people assume that preparing a statement actually speeds things up. This is not always true. The Ingres optimizer does its work based on the values in the query, and can therefore not do its work before the values actually are given (in the execute call), so a prepare does not help very much here!

Otoh I am given to understand that Oracle and others do some optimization without knowing the datavalues.

In short: YMMV. But if you discover that the prepare execute loop is faster than the select with IN, then you should probably consider changing database vendor ;-) It should be faster to issue one large query rather than a series of small queries - give or take a bit.

BTW: Don't bug gbarr about the DBI documentation. The author is Tim Bunce

  • Comment on Re: Re (3): DBI question with placeholders and IN

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-19 05:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found