Re: [SQL] Lowest 2 items per

2012-06-01 Thread Mario Dankoor
On 2012-06-01 5:44 PM, Relyea, Mike wrote: -Original Message- From: David Johnston [mailto:pol...@yahoo.com] Sent: Friday, June 01, 2012 11:13 AM To: Relyea, Mike Cc: Subject: Re: [SQL] Lowest 2 items per I would recommend using the "RANK" window function with an appropriate partition c

Re: [SQL] master/detail

2012-05-21 Thread Mario Dankoor
On 2012-05-21 1:17 AM, Jan Bakuwel wrote: Hi, I'm trying to get my head around the following question. As an example take a table with products: productid (pk) name and productprice productpriceid (pk) productid (fk) pricedate price There are multiple records in productprice for each product

Re: [SQL] bad plan

2012-04-05 Thread Mario Dankoor
Julien, I generally try avoid NOT predicates. If your geo_id is an integer, try geo_id > -1 or if it's a varchar geo_id > ''. The idea is that geo_id > 0 is false for null values. I don't think query optimizers are fond of NOT predicates. SELECT t_geo.frequence ,ST_SetSRID(gc.geom, 432

Re: [SQL] bad plan

2012-04-05 Thread Mario Dankoor
Julien, It looks like you forgot to post the query. Mario On 2012-04-05 1:38 PM, Julien Cigar wrote: Hello, I have an extremely bad plan for one of my colleague's query. Basically PostgreSQL chooses to seq scan instead of index scan. This is on: antabif=# select version();

Re: [SQL] SQL View to PostgreSQL View

2012-02-28 Thread Mario Dankoor
Hi Rehan, Whilst I'm not sure what you exactly mean with ', while this is working perfectly fine in sql,..', it's kind of odd that you get result when you execute the sql. I'd suggest looking at your search_path (show search_path), which normally resolves to 'user', 'public'; If you do h