Re: [PERFORM] Advice on optimizing select/index

2013-06-03 Thread Jeff Janes
On Wed, May 22, 2013 at 7:37 AM, Niels Kristian Schjødt < nielskrist...@autouncle.com> wrote: > > One idea I'm thinking of my self is that I have a column called state on > the adverts which can either be 'active' or 'deactivated'. The absolute > amount of 'active adverts are relatively constant (

Re: [PERFORM] SQL performance

2013-06-03 Thread Robert DiFalco
Thanks Kevin, the blocked should not be NULLABLE. I will fix that. This is with a pretty tiny dataset. I'm a little paranoid that with a large one I will have issues. Believe it or not the query became faster when I put the tests for user_id IS NOT NULL in there (and added an index for that) then

Re: [PERFORM] SQL performance

2013-06-03 Thread Kevin Grittner
Robert DiFalco wrote: > CREATE TABLE contacts > ( > id BIGINT PRIMARY KEY NOT NULL, // generated > > blocked BOOL, > owner_id BIGINT NOT NULL, > user_id BIGINT, > FOREIGN KEY ( owner_id ) REFERENCES app_users ( id ) ON DELETE CASCADE, > > FOREIGN KEY ( user_id ) REFERENC