Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Sql > Re: After updat...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 4 of 12 Topic 3425 of 3797
Post > Topic >>

Re: After updating dataset the record goes to the end of the

by craig@[EMAIL PROTECTED] (Craig Ringer) Apr 22, 2008 at 08:46 PM

Nacef LABIDI wrote:
> Yes I don't issue any sort statement, and I indeed want the data to be
show
> as it is stored in the database.
That's what you're getting. PostgreSQL has an MVCC design. How it works 
in general terms
(simplified, but I lack the expertise to give a complete explanation 
even if one was required) is:
When you update a row the old row is marked as dead and a new row is 
inserted. If there is no
spare space in the table near the old row (assuming there's any reason 
for the DB to even try
to put the new row near the old one) then the new row will be placed 
elsewhere, such as at
the end of the table.

In other words, after an UPDATE the row really is often at the end of 
the table.

In any case as others have explained you should never rely on the 
database ordering
of records; you should always use an ORDER BY if you care about order. 
The database
makes no guarantees about the order of returned rows.

The database may optimise row retrieval in ways you do not expect. For 
example,
in recent versions of PostgreSQL if there is a sequential scan in 
progress on a table
and you start another query that also runs a sequential scan on the 
table, PostgreSQL
may synchronize the two scans. That'll cause your query to start part 
way through the
table. If the table contains alphabetically ordered data you might get 
something like:

J
K
L
M
.... etc ...
A
B
C

So ... in any database, always use ORDER BY if you care about order. 
Just because it usually
works in some databases doesn't mean it won't break just rarely enough 
to drive you insane
while debugging...

--
Craig Ringer

-- 
Sent via pgsql-sql mailing list (pgsql-sql@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql
 




 12 Posts in Topic:
After updating dataset the record goes to the end of the dataset
nacef.l@[EMAIL PROTECTED]  2008-04-22 11:54:26 
Re: After updating dataset the record goes to the end of the dat
nacef.l@[EMAIL PROTECTED]  2008-04-22 12:10:41 
Re: After updating dataset the record goes to the end of the dat
depesz@[EMAIL PROTECTED]   2008-04-22 12:15:23 
Re: After updating dataset the record goes to the end of the
craig@[EMAIL PROTECTED]   2008-04-22 20:46:30 
Re: After updating dataset the record goes to the end of the dat
spam_eater@[EMAIL PROTECT  2008-04-22 12:11:42 
Re: After updating dataset the record goes to the end of the dat
singh.gurjeet@[EMAIL PROT  2008-04-22 15:42:37 
Re: After updating dataset the record goes to the end of the dat
nacef.l@[EMAIL PROTECTED]  2008-04-22 12:31:54 
Re: After updating dataset the record goes to the end of the dat
depesz@[EMAIL PROTECTED]   2008-04-22 13:02:14 
Re: After updating dataset the record goes to the end of the
padam.singh@[EMAIL PROTEC  2008-04-22 16:32:57 
Re: After updating dataset the record goes to the end of the dat
pavan.deolasee@[EMAIL PRO  2008-04-22 16:15:10 
Re: After updating dataset the record goes to the end of thedata
nacef.l@[EMAIL PROTECTED]  2008-04-22 15:00:21 
Re: After updating dataset the record goes to the end of thedata
scott.marlowe@[EMAIL PROT  2008-04-22 09:16:44 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Dec 1 9:45:11 CST 2008.