[PERFORM] low cardinality column

2003-10-03 Thread rwu . cbnco . com
Hi, I have a select like this: SELECT MAX(transactionid) FROM cbntransaction WHERE transactiontypeid=0; in the query: transactionid is the primary key of cbntransaction table, But transactiontypeid is a low cardinality column, there're over 100,000 records has the same trnsactiontypeid. I was tr

Thanks - Re: [PERFORM] low cardinality column

2003-10-02 Thread Rong Wu
Thanks, Rod, Josh and Bill, That' fantastic. have a nice day, rong :-) > Rod Taylor wrote: >> On Thu, 2003-10-02 at 14:30, Rong Wu wrote: >> >>>Hi, >>> >>>I have a select like this: >>> >>>SELECT MAX(transactionid) FROM cbntransaction WHERE transactiontypeid=0; >> >> >> For various reasons (prima

Re: [PERFORM] low cardinality column

2003-10-02 Thread Bill Moran
Rod Taylor wrote: On Thu, 2003-10-02 at 14:30, Rong Wu wrote: Hi, I have a select like this: SELECT MAX(transactionid) FROM cbntransaction WHERE transactiontypeid=0; For various reasons (primarily MVCC and the ability to make custom aggregates making it difficult) MAX() is not optimized in th

Re: [PERFORM] low cardinality column

2003-10-02 Thread Rod Taylor
On Thu, 2003-10-02 at 14:30, Rong Wu wrote: > Hi, > > I have a select like this: > > SELECT MAX(transactionid) FROM cbntransaction WHERE transactiontypeid=0; For various reasons (primarily MVCC and the ability to make custom aggregates making it difficult) MAX() is not optimized in this fashion

Re: [PERFORM] low cardinality column

2003-10-02 Thread Josh Berkus
Rong, > I have a select like this: > > SELECT MAX(transactionid) FROM cbntransaction WHERE transactiontypeid=0; Simple workaround: Create an mulit-column index on transactiontypeid, transactionid. SELECT transactionid FROM cbtransaction WHERE transactiontypeid=0 ORDER BY transactionid DESC LI

[PERFORM] low cardinality column

2003-10-02 Thread Rong Wu
Hi, I have a select like this: SELECT MAX(transactionid) FROM cbntransaction WHERE transactiontypeid=0; in the query: transactionid is the primary key of cbntransaction table, But transactiontypeid is a low cardinality column, there're over 100,000 records has the same trnsactiontypeid. I was tr