pg.ddx.io pgsql-performance@postgresql.org mailing list archivehelp / color / mirror / Atom feed
'View'-performance 2+ messages / 2 participants [nested] [flat]
* 'View'-performance @ 2003-08-14 11:42 Alexander Priem <ap@cict.nl> 0 siblings, 1 reply; 2+ messages in thread From: Alexander Priem @ 2003-08-14 11:42 UTC (permalink / raw) To: pgsql-performance Hi all, I am wondering about something: I have a table (let's call it "Table") which will contain a lot of records. Every record has a field named "deleted" which can be either NULL or a date value. When this field is NULL, the record in question may be used by a program. If the field contains a date, this field must be considered as "deleted" and cannot be used anymore. The reason why I don't actually delete such records is that I want to be able to reference them from other locations (for history purposes). What I am thinking about is creating two views for this table: Table_View and Table_History. Table_View would contain all records where "Deleted is null". Table_History would just contain all records (Select * From Table). In my program most queries would need to view only the records where deleted is null. Would " Select * from Table_View Where Name='xxx' " perform worse than " Select * from Table Where deleted is null and Name='xxx' " ? I ask this because I would like it if I wouldn't have to type "where deleted is null" for about every query in my program. But I will not use this strategy if this would mean serious performance loss... Thanks in Advance, Alexander Priem. ^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: 'View'-performance @ 2003-08-14 12:00 Tom Lane <tgl@sss.pgh.pa.us> parent: Alexander Priem <ap@cict.nl> 0 siblings, 0 replies; 2+ messages in thread From: Tom Lane @ 2003-08-14 12:00 UTC (permalink / raw) To: Alexander Priem <ap@cict.nl>; +Cc: pgsql-performance "Alexander Priem" <ap@cict.nl> writes: > What I am thinking about is creating two views for this table: Table_View a= > nd Table_History. Table_View would contain all records where "Deleted is nu= > ll". Table_History would just contain all records (Select * From Table). > Would " Select * from Table_View Where Name=3D'xxx' " perform worse than " = > Select * from Table Where deleted is null and Name=3D'xxx' " ? They'd be exactly the same (modulo a few extra microseconds/milliseconds for the query planner to expand the view definition). regards, tom lane ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2003-08-14 12:00 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2003-08-14 11:42 'View'-performance Alexander Priem <ap@cict.nl> 2003-08-14 12:00 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox