Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: [OT] SQL "on duplicate key" custom action

by haukex (Archbishop)
on Oct 21, 2019 at 15:00 UTC ( [id://11107765]=note: print w/replies, xml ) Need Help??


in reply to Re: [OT] SQL "on duplicate key" custom action
in thread [OT] SQL "on duplicate key" custom action

Thanks very much! It's not just a single import, it'll be a large import roughly once a month. So I understand you'd suggest a trigger over a unique key, may I ask why? (Performance?)

  • Comment on Re^2: [OT] SQL "on duplicate key" custom action

Replies are listed 'Best First'.
Re^3: [OT] SQL "on duplicate key" custom action
by Corion (Patriarch) on Oct 21, 2019 at 15:44 UTC

    An index across the complete table will eat up lots of disk space, and also will make each insert slow(er). Think of an index as (somewhat structured) hash keys, where you can also quickly look up strings starting with a specific string.

    If your table is largely read-only and you have the disk space to spare, the index will speed up queries maybe a bit more than an index only on the primary keys, because the DB can satisfy the query completely from the index without hitting the table storage.

    The triggers will slow down all UPDATE statements but leave SELECT untouched and also will not use additional storage.

      Ok, thank you! I do think that since the database will probably grow relatively large, I don't want to be too wasteful with the space, and slightly slower imports are probably fine. I'll try to get the trigger working and maybe I'll do a comparison with the unique key method too.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-25 09:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found