Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Re: Re: How to count rows using DBI & mysql - Performance results

by Zaxo (Archbishop)
on Jun 11, 2001 at 23:11 UTC ( [id://87619]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: How to count rows using DBI & mysql - Performance results
in thread How to count rows using DBI & mysql - Performance results

My point was to demonstrate the property of unique indexes which prevent duplication: a safety measure. I never said to use the error for program control. In fact I didn't exhibit any DBI code at all.

In practice, with the index in place:

my $known_dep=$dbi->prepare_cached("select 1 from depends where usedby +=? and uses=?"); sub known_dep ($$) {#prototype because we have a fixed number of place +holders $known_dep->execute(@_); $known_dep->rows; # 1 or 0 for unique index. }

For frequent operations, we can improve performance with the sth->bind_params() method.

We search on an index, using a pre-prepared statement handle with placeholders. That will be fast.

I didn't mention before that NULL in multiindexes is only available in MyISAM tables.

After Compline,
Zaxo

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2024-03-19 05:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found