One way to do it would be to:
Not put the percentile in the sales table;
Create an percentile table with a foreign key to the sales table primary
key and percentile int4:
CREATE TABLE percentiles(
fkey PRIMARY KEY REFERENCES sales( ),
percentile INT4 );
Create a sequence for that ancillary table
Patrick Hatcher wrote:
Scenario: Each day I update a column in a table with an internal
percentile value. To arrive at this value, I'll get a count of records
with sales > 0 and then divide this count by the total number of tile
groups I want. So for example:
Total records w/sales > 0 = 730,000
Perhaps something along the lines of
CREATE TEMP SEQUENCE pctile_seq;
SELECT ... , ((nextval('pctile_seq')/(rec_per_group+1) +1)
FROM (SELECT ... WHERE sales > 0 ORDER BY SALES) sales;
DROP TEMP SEQUENCE pctile_seq;
This doesn't add in the 'sales = 0 are in percentile 0, but that
shouldn't be too
pg: 7.4.2
RedHat 7.2
Can I get some advice on a possible faster way of doing this:
Scenario: Each day I update a column in a table with an internal
percentile value. To arrive at this value, I'll get a count of records
with sales > 0 and then divide this count by the total number of tile
g
Tom,
Does java.sql.PreparedStatement do the same thing as SQL command
prepare/execute ??
Which one should be used while I am using jdbc talking to postgresql? If
using both, do them help the performance?
Thanks.
Jie Liang
-Original Message-
From: Jie Liang
Sent: Monday, June 14, 200
On Tue, 2004-06-15 at 03:05, Andrei Bintintan wrote:
> "Is it safe to use "select max(table1_id) from table1" after the insert?"
>
> Yes it is safe, but ONLY if you use it inside a transaction.(BEGIN/COMMIT).
No, this is not safe outside of the serializable isolation.
rbt=# begin;
BEGIN
rbt=# se
"Is it safe to use "select max(table1_id) from table1" after the insert?"
Yes it is safe, but ONLY if you use it inside a transaction.(BEGIN/COMMIT).
BR.
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of mixo
Sent: Wednesday, June 09, 2004 9:24 AM
To: [EM