Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

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

by Zaxo (Archbishop)
on Jun 11, 2001 at 23:11 UTC ( #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


Comment on Re: Re: Re: How to count rows using DBI & mysql - Performance results
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (6)
As of 2014-10-02 05:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (49 votes), past polls