[SQL] minimum bounding circle for a triangle/polygon

2007-08-22 Thread George Pavlov
before i start reinventing the wheel does anyone have handy a function (or straight SQL) for calculating the centerpoint coordinates and the radius of the minimum bounding circle (not the the circumcircle) of a triangle (coordinates of 3 points given as inputs). a bonus would be a generalizati

Re: [SQL] Partial index and query plan

2007-08-22 Thread Aleksandr Vinokurov
Scott Marlowe wrote: > > I don't see the issue here. The index being used is the same partial > index you created. Maybe it's just a question of semantics? > As I understand final filter is: a) pointed at the index creation b) is redundant as all the indexed records have action

Re: [SQL] Partial index and query plan

2007-08-22 Thread Scott Marlowe
On 8/22/07, Aleksandr Vinokurov <[EMAIL PROTECTED]> wrote: > > create table user_history ( >rec_id SERIAL not null, >date TIMESTAMPnot null, >action INT2 not null, >uid INT4 not

Re: [SQL] Partial index and query plan

2007-08-22 Thread Aleksandr Vinokurov
Thank you Tom, but does it means that this is only an explain's problem or the plan is actually such a hard, and postmaster actually checks each record found by the index with this "filter"? I'm using 8.0.1 version, but upgrading can become a work with expense. On 22/08/07, Tom Lane <[EMAIL PROT

Re: [SQL] Partial index and query plan

2007-08-22 Thread Tom Lane
"Aleksandr Vinokurov" <[EMAIL PROTECTED]> writes: > The question is why "explain analyze" shows a 'Filter: ("action" <> 0)' in > plan: Use a newer Postgres release (8.1 or later). regards, tom lane ---(end of broadcast)---

Re: [SQL] Solution to retrieve first and last row for each minute

2007-08-22 Thread Christian Kindler
Its really slow but what you can do is something like the following: select count(a.*), b.* from foo.bar a, ( select price from foo.bar order by time asc limit 1 union select price from foo.bar order by time desc limit 1 ) as b group by b.price ... just do the "wheres" as you need ... Chris

[SQL] Partial index and query plan

2007-08-22 Thread Aleksandr Vinokurov
Hello all, Imagine having this table: create table user_history ( rec_id SERIAL not null, date TIMESTAMPnot null, action INT2 not null, uid INT4 not null, name C

Re: [SQL] Solution to retrieve first and last row for each minute

2007-08-22 Thread roopa perumalraja
Hi Christian, Thanks for your reply. Is it possible to use sub query to do this without using the IF ELSE LOOP? Cheers Roopa Christian Kindler <[EMAIL PROTECTED]> wrote: Hi! Do something like this http://fimi.cvs.sourceforge.net/fimi/database/defaults/indicators/myinttick2bar.

Re: [SQL] raw data into table process

2007-08-22 Thread Steve Midgley
Hi, I'm not sure if you have access to a scripting language (like perl or ruby) but my experience is that if you transform the source text file into a secondary text file that postgres "copy" can read natively/directly into the data formats you want, the copy command will move everything into

[SQL] Database creation script

2007-08-22 Thread Dani CastaƱos
Hi all! I'm building a database creation script, and i want to modularize it. Now, I'm trying something like: /* - Customer creation script - Version : 1.0.0 */ \set ON_ERROR_STOP 1 \set AUTOCOMMIT off BEGIN; \i languages_and_countries.sql \i app_1.sql \i app_2.sql [...] END; What do you

Re: [SQL] Solution to retrieve first and last row for each minute

2007-08-22 Thread Christian Kindler
Hi! Do something like this http://fimi.cvs.sourceforge.net/fimi/database/defaults/indicators/myinttick2bar.sql?revision=1.3&view=markup and replace the max / min calculation with a count calculation. Cheers Chris On Wed, August 22, 2007 9:25 am, roopa perumalraja wrote: > Hi all, > > I ha

[SQL] Solution to retrieve first and last row for each minute

2007-08-22 Thread roopa perumalraja
Hi all, I have a table trans with the data price | volume | date | time ---+++-- 79.87 |500 | 2006-06-01 | 13:30:14.262 79.87 |900 | 2006-06-01 | 13:30:15.375 79.85 |200 | 2006-06-01 | 13:30:17.381 79.85 |500 | 2006-06-01 |