Re: best index for timestamp field null and not null queries

From: Romain Billon-Grand <billongrand(at)hotmail(dot)fr>
To: <jemmyw(at)gmail(dot)com>, <pgsql-novice(at)postgresql(dot)org>
Subject: Re: best index for timestamp field null and not null queries
Date: 2012-08-26 11:41:03
Message-ID: COL118-W22B10335F46DCE0EA58AE7CEA30@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice


Hi Well I do not pretend to give an answer, it is rather a question -I am a novice in postgresql two!-Why not to split the table in two, the second ones inherits the first. Your datetime column is present only in the daughter. Parent table are undeleted, daughter one are deleted. A trigger on the parent table fils the daughter one for DELETE queries, and you can make your queries on the parent one with SELECT ONLY or SELECT depending on your need to have or not to have the deleted rows
Hopefully, expert will provide us with the advantages and drawbacks of both solutions!Romain
Date: Sun, 26 Aug 2012 19:08:36 +1200
From: jemmyw(at)gmail(dot)com
To: pgsql-novice(at)postgresql(dot)org
Subject: [NOVICE] best index for timestamp field null and not null queries


Hi, I've got a database table with a datetime column "deleted_at". I'll be running lots of queries against the table but they'll all be of the nature "deleted_at IS NULL" and "deleted_at IS NOT NULL".

What's the best index to place on this column? I assume if I add just a straight index then it'll index all of the values that go into it.

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Bruce Momjian 2012-08-26 13:47:01 Re: [NOVICE] index refuses to build
Previous Message Gavin Flower 2012-08-26 09:35:29 Re: best index for timestamp field null and not null queries