Re: Database

From: Date: Wed, 08 Nov 2000 21:31:38 +0000
Subject: Re: Database
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-24389@lists.php.net to get a copy of this message
=== Glover George escribia (Wed, Nov 08, 2000 at 11:39:35AM -0600): > Hope this not off topic, but if it is just scold me! I am using postgresql <snip> > > Anyway, what I'm wondering is when you insert into the database, is the new > record necessarily always going to be the last record in the database table? > In otherwords, to find out the last directory I wrote to can I simply pull > the last row out of the table? Is it sequential? The database engine doesn't necessarily guarantee any given order when retrieving tuples, if you need ordering you should use the ORDER BY clause. > Also, if I can just pull out the last row to find out what the last one is > that I wrote to, is there anyway to do this on the order of magnitude of > O(1)? or is the only way O(n)? Now I am using ODBC for this and can't use > any of the functionality with the pg_... calls. I need an extremely > efficient way of determining this as it is time critical and I don't want to > have to wait. I'd say include a timestamp in the table and declare an index on that column, then SELECT * FROM <table> WHERE <timestamp> = (SELECT MAX(<timestamp>) FROM <table>); I'd like to hear comments about this proposal though. > Thanks a lot. It may sound vague, but I can explain a little more if > necessary. Enough thanks :) Manuel Garcia

« previous php.general (#24389) next »