From: | "Ethan Collins" <collins(dot)ethans+psql(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | accessing table in LIFO order |
Date: | 2008-06-06 22:55:09 |
Message-ID: | 9fb37e4a0806061555m2da30e26id3ceed79dee07ba7@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I have got a table that holds 2 columns: date_id and info. date_id is
bigint, created as, for eg. 17 May 2008, 19:05 hrs => 200805171905. This
table is populated with {date, info} pair that I receive frequently. AND
there can be mltiple such entries with a single date_id but varying info,
for eg. 20 entries with same date_id but different info. I haven't created
any primary key or index.
I use query that looks like this:
SELECT date_id, info FROM netproto_entries ORDER BY date_id DESC
LIMIT <limit_val>;
Questions:
- For higher values of limit_val (say 70/75/..), when I change it, the order
in which I get the entries changes. Eg. it shows me one info at the top at
one time, and another on the next time with a different value of
limit_val.
- My intent is to fetch the entries from the database in LIFO order, most
recently entered entry at the top. For the elements with the date_id being
the same, they are not in LIFO order. I understand that I can add another
incrementing index column and sort the table based on that. But, without
adding this,
does postgresql have any method/configuration to get me output in LIFO
order ?
And are there any better methods available compared to adding another
index
column (as mentioned above) ?
Thanks,
Ethan
From | Date | Subject | |
---|---|---|---|
Next Message | Celso Pinto | 2008-06-07 00:05:08 | array column and b-tree index allowing only 8191 bytes |
Previous Message | Ethan Collins | 2008-06-06 21:46:05 | accessing table in LIFO order |