Re: tricky CHECK condition
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Arcady Genkin <a.genkin@utoronto.ca>
Cc: pgsql-general@postgresql.org
Date: 2000-05-23T05:11:39Z
Lists: pgsql-general
Arcady Genkin <a.genkin@utoronto.ca> writes: > I want to check values of `track_number' to be unique for the > disk. Not sure if it can be done with a CHECK condition, but the traditional solution is to create a unique index on the two columns: create unique index tracks_disk_track_i on tracks(disk_id, track_number); Updating an index should be a lot faster than running a whole subquery for each insert, and the planner may be able to use the index to speed up other queries too. So, it's a win all round... regards, tom lane