Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

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

by Brovnik (Hermit)
on Jun 11, 2001 at 18:45 UTC ( #87509=note: print w/ replies, xml ) Need Help??


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

But I want to be able to have multiple rows with the same key/column1,
Unique keys prevent that.
--
Brovnik


Comment on Re: Re: How to count rows using DBI & mysql - Performance results
Re: Re: Re: How to count rows using DBI & mysql - Performance results
by hding (Chaplain) on Jun 11, 2001 at 19:07 UTC

    Then why do you need to do an "INSERT ... IF NOT EXISTS"? (Note that if you're trying to enforce the uniqueness of some combination of columns, you can make the index on all of the columns; maybe this is what you mean.)

(Unique Index) Re x 3: How to count rows using DBI & mysql - Performance results
by Zaxo (Archbishop) on Jun 11, 2001 at 19:25 UTC

    hding is right. In that case, declare a multicolumn unique index. That does precisely what you are asking for. MySQL will look at the first column first, so it should be the more unique. [OB] A table needs a primary key.

    create table depends (uses varchar(80) not null, usedby varchar(80) not null, unique deps (usedby,uses)); # naming the index is unnecessary, but may be a convenience

    Btw, why not represent a leaf node by usedby=NULL? That would give a faster select for leaf/branch.

    After Compline,
    Zaxo

Re: Re: Re: How to count rows using DBI & mysql - Performance results
by elwarren (Curate) on Jun 11, 2001 at 22:38 UTC
    In this case you should have a one to many foreign key relationship to a second table. This table would contain a unique column with all of your modules in it. Insert into this table, catch the exception if it happens.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (17)
As of 2014-07-24 17:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (163 votes), past polls