Re: [SQL] window function to sort times series data?

2010-03-24 Thread Louis-David Mitterrand
On Wed, Mar 24, 2010 at 03:29:36PM +0100, A. Kretschmer wrote: > In response to Louis-David Mitterrand : > > Hi, > > > > I have time series data: price(id_price int, price int, created_on > > timestamp) > > > > I'd like to select the latest price befo

Re: [SQL] window function to sort times series data?

2010-03-24 Thread Louis-David Mitterrand
On Wed, Mar 24, 2010 at 05:29:46PM +0100, Andreas Kretschmer wrote: > A. Kretschmer wrote: > > Well, and now i'm using 8.4 windowing-functions: > > test=*# select * from price order by price_id, d; > price_id | price | d > --+---+ > 1 |10 | 2010-03-12 >

Re: [SQL] Does IMMUTABLE property propagate?

2010-03-24 Thread Louis-David Mitterrand
On Sat, Mar 06, 2010 at 04:31:55PM -0500, Tom Lane wrote: > Petru Ghita writes: > > "..immediately replaced with the function value" doesn't mean that the > > results of a previously evaluated function for the same parameters are > > stored and reused? > > No, it means what it says: the function

Re: [SQL] Does IMMUTABLE property propagate?

2010-03-25 Thread Louis-David Mitterrand
On Thu, Mar 25, 2010 at 08:27:27AM +0100, Pavel Stehule wrote: > 2010/3/25 Louis-David Mitterrand : > > On Sat, Mar 06, 2010 at 04:31:55PM -0500, Tom Lane wrote: > >> Petru Ghita writes: > >> > "..immediately replaced with the function value" doesn't

[SQL] graphing time series data

2010-04-14 Thread Louis-David Mitterrand
Hi, I have times series data in a 'price' table: price(id_price, price, id_product, created, modified) Prices are polled daily and a new 'price' row is created only if the price of id_product changes, else modified is updated to now(). Now, I'd like to make a graph of average prices per week, p

Re: [SQL] graphing time series data

2010-04-14 Thread Louis-David Mitterrand
On Wed, Apr 14, 2010 at 08:46:13AM -0700, Richard Broersma wrote: > On Wed, Apr 14, 2010 at 7:54 AM, Louis-David Mitterrand > wrote: > > > Now, I'd like to make a graph of average prices per week, per > > id_product. As some prices don't vary much, distribution wou

Re: [SQL] graphing time series data

2010-04-14 Thread Louis-David Mitterrand
On Wed, Apr 14, 2010 at 06:06:59PM +0200, Pavel Stehule wrote: > I don't understand well. Why you don't use a function date_trunc(), > > select date_trunc('week', created), count(*) > from price > group by date_trunc('week', created) Because if a price doesn't change for more than a week, then so

[SQL] best paging strategies for large datasets?

2010-05-11 Thread Louis-David Mitterrand
Hi, I have a large dataset (page 1 at http://www.cruisefish.net/stat.md) and am in the process of developping a pager to let users leaf through it (30K rows). Ideally I'd like to know when requesting any 'page' of data where I am within the dataset: how many pages are available each way, etc. Of

Re: [SQL] best paging strategies for large datasets?

2010-05-13 Thread Louis-David Mitterrand
On Wed, May 12, 2010 at 12:26:17PM -0400, Justin Graf wrote: > oops typos > On 5/12/2010 1:41 AM, Louis-David Mitterrand wrote: > > Hi, > > > > I have a large dataset (page 1 at http://www.cruisefish.net/stat.md) and > > am in the process of developping a page

Re: [SQL] best paging strategies for large datasets?

2010-05-13 Thread Louis-David Mitterrand
On Thu, May 13, 2010 at 11:36:53AM +0400, silly sad wrote: > On 05/12/10 09:41, Louis-David Mitterrand wrote: > >Hi, > > > >I have a large dataset (page 1 at http://www.cruisefish.net/stat.md) and > >am in the process of developping a pager to let users l

[SQL] safely exchanging primary keys?

2010-05-24 Thread Louis-David Mitterrand
Hi, I have this function which swaps primary keys for cabin_types (so that id_cabin_type ordering reflects natural data ordering): CREATE OR REPLACE FUNCTION swap_cabin_types(id1 integer, id2 integer) RETURNS integer AS $$ declare tmp integer;

Re: [SQL] safely exchanging primary keys?

2010-05-24 Thread Louis-David Mitterrand
On Mon, May 24, 2010 at 10:51:01AM +0200, Louis-David Mitterrand wrote: > Hi, > > I have this function which swaps primary keys for cabin_types (so that > id_cabin_type ordering reflects natural data ordering): Actually this function works fine. My problem was elsewhere. Sorry for ba

Re: [SQL] safely exchanging primary keys?

2010-05-24 Thread Louis-David Mitterrand
On Mon, May 24, 2010 at 02:38:39PM +, Tim Landscheidt wrote: > Louis-David Mitterrand wrote: > > What does "are not properly updated" mean? Anyhow, why don't Hi, I did follow-up on my own post: the problem was elsewhere. > you use something simple like (untested

Re: [SQL] safely exchanging primary keys?

2010-05-24 Thread Louis-David Mitterrand
On Mon, May 24, 2010 at 07:00:30PM +0200, Louis-David Mitterrand wrote: > On Mon, May 24, 2010 at 02:38:39PM +, Tim Landscheidt wrote: > > you use something simple like (untested): > > > > | UPDATE cabin_type > > | SET id_cabin_type = > > | CASE > >

Re: [SQL] subtract two dates to get the number of days

2010-07-14 Thread Jean-David Beyer
allowed a date datatype where I could add, subtract, and so on. I use it in programs that do not necessarily use a database, but also in programs that do when the computations are the big part of the cpu load, as contrasted to just "gentle" massaging of existing data. - -- .~. J

Re: [SQL] subtract two dates to get the number of days

2010-07-14 Thread Jean-David Beyer
Thomas Kellerer wrote: > Jean-David Beyer wrote on 14.07.2010 14:37: >> My dates are of the form -mm-dd and such. > Storing a date as a string is never a good idea. I started this long ago, when postgreSQL did not really work very well (1998?). One version of it would not d

[SQL] "compressing" consecutive values into one

2010-11-23 Thread Louis-David Mitterrand
Hi, On time series price data I'm trying to remove consecutive identical prices and keep only the latest. I tried: delete from price where id_price in (select t.id_price2 from (select first_value(p.id_price) over w as id_price1, nth_value(p.

Re: [SQL] "compressing" consecutive values into one

2010-11-23 Thread Louis-David Mitterrand
On Tue, Nov 23, 2010 at 03:31:59PM -, Oliveiros d'Azevedo Cristina wrote: > Salut, Louis-David, > > Can you please state the columns belonging to price table > and give a concrete example? > Say, data before and data after you want to do? Hi Cristina, Data before:

Re: [SQL] "compressing" consecutive values into one

2010-11-24 Thread Louis-David Mitterrand
On Tue, Nov 23, 2010 at 04:19:18PM +0100, Louis-David Mitterrand wrote: > Hi, > > On time series price data I'm trying to remove consecutive identical > prices and keep only the latest. I tried: > > delete from price where id_price in (select t

Re: [SQL] Database consistency after a power shortage

2010-12-16 Thread Jean-David Beyer
do not know how long it takes to do such a shutdown with postgreSQL, but it could involve stopping all new transactions from entering the system, and allowing those in process to complete. A UPS to allow 10 minutes of run-time is not normally considered too expensive. Mine will run for about an hour

Re: [SQL] foreign keys and lots of tables

2011-05-18 Thread David W Noon
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* dwn...@ntlworld.com (David W Noon) *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* signature.asc Description: PGP signature

[SQL] Cursor names in a self-nested function

2011-08-18 Thread Kidd, David M
s. Any other solutions are of cause welcome. Many thanks, - David David M. Kidd Research Associate Center for Population Biology Silwood Park Campus Imperial College London 0207 594 2470

[SQL] organizing cron jobs in one function

2012-11-17 Thread Louis-David Mitterrand
Hi, I'm planning to centralize all db maintenance jobs from a single pl/pgsql function called by cron every 15 minutes (highest frequency required by a list of jobs). In pseudo code: CREATE or replace FUNCTION cron_jobs() RETURNS void LANGUAGE plpgsql AS $$ DECLARE rec record; BEGIN /*

Re: [SQL] organizing cron jobs in one function

2012-11-18 Thread Louis-David Mitterrand
On Sun, Nov 18, 2012 at 07:27:54PM +0800, Craig Ringer wrote: > On 11/18/2012 12:19 AM, Louis-David Mitterrand wrote: > > Hi, > > > > I'm planning to centralize all db maintenance jobs from a single > > pl/pgsql function called by cron every 15 minutes (highest fre

Re: [SQL] organizing cron jobs in one function

2012-11-19 Thread Louis-David Mitterrand
On Mon, Nov 19, 2012 at 08:31:10AM +0800, Craig Ringer wrote: > On 11/19/2012 01:11 AM, Louis-David Mitterrand wrote: > > On Sun, Nov 18, 2012 at 07:27:54PM +0800, Craig Ringer wrote: > >> On 11/18/2012 12:19 AM, Louis-David Mitterrand wrote: > >>> Hi, > >>&g

[SQL] list variable attributes in one select

2007-01-21 Thread Louis-David Mitterrand
Hello, I've got the following tables: person: - id_person - firstname - lastname - type person_to_type: - id_person references person - type references person_type; person_type: - type "person_type" contains differents caracteristics for a person (actor, director, author, etc.) who can have s

[SQL] sub-limiting a query

2007-02-17 Thread Louis-David Mitterrand
Hello, I've got a table of shows with different types (movie, theater, ballet,etc.) and I am looking for a select that can return the 10 last entered shows AND at most 2 of each type. Is that possible in one query? The table looks basically like: created_on | timestamp without tim

Re: [SQL] sub-limiting a query

2007-02-17 Thread Louis-David Mitterrand
On Sat, Feb 17, 2007 at 07:21:40PM +0100, M.P.Dankoor wrote: > Louis-David Mitterrand wrote: > > > I thought of another solution, actually it's of those top n query tricks > that I picked up somewhere, can't remember > where. > Assuming that your table is ca

[SQL] simple web search

2007-02-23 Thread Louis-David Mitterrand
Hello, I'm considering implementing a search box on my review web site http://lesculturelles.net and am looking for a simple way to match entered words against several columns on related tables: show.show_name, story.title, person.firtname, person.lastname, etc. What is the most elegant way to

Re: [SQL] simple web search

2007-02-23 Thread Louis-David Mitterrand
On Fri, Feb 23, 2007 at 10:01:22AM -0800, chester c young wrote: > > I'm considering implementing a search box on my review web site > > http://lesculturelles.net and am looking for a simple way to match > > entered words against several columns on related tables: > > show.show_name, story.title,

Re: [SQL] simple web search

2007-02-23 Thread Louis-David Mitterrand
On Fri, Feb 23, 2007 at 01:31:14PM -0500, Joe wrote: > Hello Louis-David, > > On Fri, 2007-02-23 at 17:27 +0100, Louis-David Mitterrand wrote: > > I'm considering implementing a search box on my review web site > > http://lesculturelles.net and am looking for a simple

[SQL] getting at sequence previous/next values

2007-02-26 Thread Louis-David Mitterrand
Hello, I've got a table that looks basically like: id_show | serial show_name | text show_type | text created_on | timestamp without time zone When looking at a row with an id_show of value n, I'd like to have an

[SQL] query to select a linked list

2007-05-09 Thread Louis-David Mitterrand
Hi, To build a threaded forum application I came up the following schema: forum -- id_forum | integer| not null default nextval('forum_id_forum_seq'::regclass) id_parent| integer| subject | text | not null message | text | Each message a unique id_forum and an id_parent pointing to

Re: [SQL] query to select a linked list

2007-05-09 Thread Louis-David Mitterrand
On Wed, May 09, 2007 at 02:24:22PM +0100, Gregory Stark wrote: > "Louis-David Mitterrand" <[EMAIL PROTECTED]> writes: > > > Each message a unique id_forum and an id_parent pointing to the replied > > post (empty if first post). > > > > How can I buil

Re: [SQL] query to select a linked list

2007-05-09 Thread Louis-David Mitterrand
On Wed, May 09, 2007 at 02:55:20PM +0200, Louis-David Mitterrand wrote: > Hi, > > To build a threaded forum application I came up the following schema: > > forum > -- > id_forum | integer| not null default nextval('forum_id_forum_seq'::regclass) > id_p

Re: [SQL] query to select a linked list

2007-05-09 Thread Louis-David Mitterrand
On Wed, May 09, 2007 at 04:30:21PM +0200, Louis-David Mitterrand wrote: > On Wed, May 09, 2007 at 02:55:20PM +0200, Louis-David Mitterrand wrote: > > Hi, > > > > To build a threaded forum application I came up the following schema: > > > > forum > >

Re: [SQL] query to select a linked list

2007-05-10 Thread Louis-David Mitterrand
On Thu, May 10, 2007 at 09:49:32AM +1000, Robert Edwards wrote: > > Hi Louis-David, > > I also have written a forum application using PostgreSQL. > > My schema has a "threadid" for each posting, which is actually also the > "messageid" of the first post

[SQL] Embedded C++ with ecpg?

2007-06-22 Thread Jean-David Beyer
these programs in C. Red Hat seem to be on postgresql version 8.1.4 for the initial release of RHEL5, and they may have updates a little higher. -- .~. Jean-David Beyer Registered Linux User 85642. /V\ PGP-Key: 9A2FC99A Registered Machine 241939. /( )\ Shrewsbury, New J

Re: [SQL] Embedded C++ with ecpg?

2007-06-22 Thread Jean-David Beyer
Tom Lane wrote: > Jean-David Beyer <[EMAIL PROTECTED]> writes: >> What is the current status of (pre) compiling Embedded SQL in C++ programs? > > I just asked Michael Meskes about that (had you put a support request > into Red Hat asking this?). Yes, and Red Hat's

Re: [SQL] another simple SQL question

2007-06-25 Thread Jean-David Beyer
ook here: http://ieeexplore.ieee.org/xpl/freeabs_all.jsp?tp=&arnumber=810466&isnumber=16537 for one way to do this. It explains briefly how to make a suitable index for it. -- .~. Jean-David Beyer Registered Linux User 85642. /V\ PGP-Key: 9A2FC99A Registered Mac

[SQL] how to download linux 7.3 image

2007-07-22 Thread Jean-David Beyer
ion of postgreSQL that will run on RHL 7.3, that might be a problem since the current versions of postgreSQL probably all demand a much newer kernel (RHL 7.3 used a 2.2 kernel, IIRC) and associated libraries. -- .~. Jean-David Beyer Registered Linux User 85642. /V\ PGP-Key: 9A

[SQL] is there a 'table' data type in pg?

2007-07-24 Thread Louis-David Mitterrand
Hello, In my forum app a new post can be related to several types of objects: person, location, event, simple text subject, etc. so in my 'forum' table I plan to add an id_subject column which can contain a reference to any number of different tables (location, person, etc.). What I need to kn

Re: [SQL] is there a 'table' data type in pg?

2007-07-24 Thread Louis-David Mitterrand
On Tue, Jul 24, 2007 at 03:10:44PM +0100, Gregory Stark wrote: > "Louis-David Mitterrand" <[EMAIL PROTECTED]> writes: > > > Can I use a another column to store the type of the id_subject (ie: the > > tabled it belongs to) ? Then I would be able to query that

[SQL] inheriting a rule or a trigger?

2007-07-24 Thread Louis-David Mitterrand
Hi, I'm trying to protect created_by and created_on columns from accidental update. Most of my tables inherit from a 'source' table that has those columns, so I was thinking of creating a rule or trigger that does nothing on update to these columns. But apparently rules and triggers don't appl

[SQL] Starting autovacuum in postgresql-8.1.9

2007-08-16 Thread Jean-David Beyer
t. Is it built into the server now, or is it to be found somewhere else? In particular, pgavd does not exist anywhere on my system. - -- .~. Jean-David Beyer Registered Linux User 85642. /V\ PGP-Key: 9A2FC99A Registered Machine 241939. /( )\ Shrewsbury, New Jersey

[SQL] there is already a transaction in progress ?

2007-08-18 Thread Jean-David Beyer
sequences with this kind of thing: ALTER SEQUENCE company_company_id_seq RESTART WITH 1; before running the test program. -- .~. Jean-David Beyer Registered Linux User 85642. /V\ PGP-Key: 9A2FC99A Registered Machine 241939. /( )\ Shrewsbury, New Jerseyhttp://co

Re: [SQL] there is already a transaction in progress ?

2007-08-18 Thread Jean-David Beyer
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Jean-David Beyer wrote: > It probably shows I am new to postgreSQL. I recently started running this > instead of DB2, and am converting the applications I already wrote. These > use ecpg. > > The problem I have concerns transact

[SQL] Block size with pg_dump?

2007-08-26 Thread Jean-David Beyer
I suppose to make any blocksize I want. On the way back, likewise I could pipe the tape through dd before giving it to pg_restore. Does pg_dump care what blocksize it gets? If so, what is it? - -- .~. Jean-David Beyer Registered Linux User 85642. /V\ PGP-Key: 9A2FC99A

Re: [SQL] Block size with pg_dump?

2007-08-26 Thread Jean-David Beyer
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Bruce Momjian wrote: > Jean-David Beyer wrote: >> -BEGIN PGP SIGNED MESSAGE- >> Hash: SHA1 >> >> When I make a backup of a database, I put the output file directly on >> magnetic tape; i.e., my command look

Re: [SQL] Block size with pg_dump?

2007-08-27 Thread Jean-David Beyer
) uses 8K blocks. > > That is true of the internal storage, but not of pg_dump's output > because it is using libpq to pull rows and output them in a stream, > meaning there is no blocking in pg_dumps output itself. > Is that true for both input and output (i.e., pg_restore

Re: [SQL] Block size with pg_dump?

2007-08-27 Thread Jean-David Beyer
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Bruce Momjian wrote: > Jean-David Beyer wrote: >>>>> The main question is, If I present pg_restore with a 65536-byte >>>>> blocksize >>>>> and it is expecting, e.g., 1024-bytes, will the rest of each

Re: [SQL] How to use serial variable to insert into muiti-recrods?

2007-09-06 Thread Jean-David Beyer
umber in multiple records, then you should get the serial number direct from the SEQUENCE and plug it in each tuple as you need it. - -- .~. Jean-David Beyer Registered Linux User 85642. /V\ PGP-Key: 9A2FC99A Registered Machine 241939. /( )\ Shrewsbury, New Jerseyh

[SQL] Is there anything special about pg_dump's compression?

2007-11-15 Thread Jean-David Beyer
drive claims 2:1 compression for average data (e.g., not already compressed stuff like .jpeg files). -- .~. Jean-David Beyer Registered Linux User 85642. /V\ PGP-Key: 9A2FC99A Registered Machine 241939. /( )\ Shrewsbury, New Jerseyhttp://counter.li.org ^^-^^ 10:50:0

Re: [SQL] Is there anything special about pg_dump's compression?

2007-11-15 Thread Jean-David Beyer
Andrew Sullivan wrote: > On Thu, Nov 15, 2007 at 11:05:44AM -0500, Jean-David Beyer wrote: >> Does pg_dump's compression do anything really special that it is not >> likely the tape drive already does? The drive claims 2:1 compression >> for average data (e.g., not alr

Re: [SQL] Is there anything special about pg_dump's compression?

2007-11-16 Thread Jean-David Beyer
Tom Lane wrote: > Jean-David Beyer <[EMAIL PROTECTED]> writes: >> I turned the software compression off. It took: >> 524487428 bytes (524 MB) copied, 125.394 seconds, 4.2 MB/s > >> When I let the software compression run, it uses only 30 MBytes. So whatever >>

Re: [SQL] Is there anything special about pg_dump's compression?

2007-11-16 Thread Jean-David Beyer
Shane Ambler wrote: > Jean-David Beyer wrote: >>> The physical tape speed is surely the real bottleneck here, and the >>> fact that the total elapsed time is about the same both ways proves >>> that about the same number of bits went onto tape both ways. >> &

[SQL] dynmic column names inside trigger?

2007-11-20 Thread Louis-David Mitterrand
Hi, I've got this trigger to clean up text entered in web forms: CREATE or replace FUNCTION sanitize_text() RETURNS "trigger" AS $$ declare begin if old.story is not null and new.story != old.story then

Re: [SQL] dynmic column names inside trigger?

2007-11-22 Thread Louis-David Mitterrand
On Wed, Nov 21, 2007 at 09:14:14AM +0100, Bart Degryse wrote: > I would do something like this (not tested, but conceptually working): Hello, > BEGIN > if old.story is not null and new.story != old.story then > new.story = sanitize_text(new.story); > end if; > --checks on other field can be inc

Re: [SQL] dynmic column names inside trigger?

2007-11-22 Thread Louis-David Mitterrand
On Tue, Nov 20, 2007 at 11:56:02AM -0500, Tom Lane wrote: > Louis-David Mitterrand <[EMAIL PROTECTED]> writes: > > I'd like to use it on other tables an columns but how can the column > > name be dynamic inside the procedure. > > It can't --- plpgsql has no

Re: [SQL] dynmic column names inside trigger?

2007-11-23 Thread Louis-David Mitterrand
On Wed, Nov 21, 2007 at 09:14:14AM +0100, Bart Degryse wrote: > I would do something like this (not tested, but conceptually working): > > CREATE or replace FUNCTION sanitize_text(webtext IN text, cleantext OUT text) > AS > $body$ > BEGIN > cleantext = translate(webtext, E'\x92\x96', '''-'); > c

[SQL] passing a multiple join to a function?

2007-12-17 Thread Louis-David Mitterrand
Hi, I've got this ugly case statement that I'd like to hide in a function: select ... case when d.start_date <= CURRENT_DATE and case when w.show_type in ('cinéma','livre') then d.start_date >= CURRENT_DATE - 21

Re: [SQL] passing a multiple join to a function?

2007-12-23 Thread Louis-David Mitterrand
On Mon, Dec 17, 2007 at 12:27:34PM -0500, Rodrigo De León wrote: > On 12/17/07, Louis-David Mitterrand <[EMAIL PROTECTED]> wrote: > > I've got this ugly case statement that I'd like to hide in a function: > > Why don't you hide the entire query in a VIEW?

[SQL] returning an array as a list fo single-column rows?

2007-12-23 Thread Louis-David Mitterrand
Hi, is there a way to return a Pg array as a list of single-column row values? I am trying to circumvent DBI's lack of support for native database arrays and return the list of values from an ENUM as a perl array. Thanks, ---(end of broadcast)--

Re: [SQL] returning an array as a list fo single-column rows?

2007-12-23 Thread Louis-David Mitterrand
On Sun, Dec 23, 2007 at 10:19:26PM +0100, Pavel Stehule wrote: > Hello > > try > > create or replace function unpack(anyarray) > returns setof anyelement as $$ > select $1[i] > from generate_series(array_lower($1,1), array_upper($1,1)) g(i); > $$ language sql; > > postgres=# select * from

Re: [SQL] returning an array as a list fo single-column rows?

2007-12-23 Thread Louis-David Mitterrand
On Sun, Dec 23, 2007 at 10:27:09PM +0100, Pavel Stehule wrote: > On 23/12/2007, Louis-David Mitterrand > <[EMAIL PROTECTED]> wrote: > > Hi, > > > > is there a way to return a Pg array as a list of single-column row > > values? > > > > I am tryin

Re: [SQL] EPOCH TIMESTAMP Conversion Problem

2008-01-01 Thread Louis-David Mitterrand
On Wed, Nov 07, 2007 at 10:35:08AM -0500, Tom Lane wrote: > "Amitanand Chikorde" <[EMAIL PROTECTED]> writes: > > I want to convert MAX(mydate) from myTable to Epoch. > > Do you mean > SELECT EXTRACT(EPOCH FROM MAX(mydate)) FROM myTable Is using casts for the same purpose deprecated?

Re: [SQL] Check before INSERT INTO

2008-02-11 Thread Jean-David Beyer
l)? Would this not fix your problem especially if you have a SERIAL as primary key? > > I though it was possible to change the SQL string before it does the > update.. But i can't seem to find a solution for it.. Any idea ?? > -- .~. Jean-David Beyer Re

Re: [SQL] How to find double entries

2008-04-19 Thread Jean-David Beyer
parate record: U S Government Federal Aviations Administration Kennedy Airport Pilot Information Arrivals Departures We had to make it find "Pilot Arrivals" so indexing was not trivial until you figured out how to do it. But when all was said an

[SQL] Curious about wide tables.

2008-04-27 Thread Jean-David Beyer
criticising the O.P., since I know nothing about his application, I am curious how it comes about that such a wide table is justified. -- .~. Jean-David Beyer Registered Linux User 85642. /V\ PGP-Key: 9A2FC99A Registered Machine 241939. /( )\ Shrewsbury, New Jerseyhttp

Re: [SQL] Curious about wide tables.

2008-04-30 Thread Jean-David Beyer
Shane Ambler wrote: > Jean-David Beyer wrote: >> In another thread, the O.P. had a question about a large table with >> over 100 columns. Is this usual? Whenever I make a database, which is >> not often, it ends up with tables that rarely have over to columns, and >> u

[SQL] dynamic events categorization

2008-06-24 Thread Louis-David Mitterrand
Hello, I'm looking for a more efficient way of dynamically categorizing some events. The following view definition looks into each event's latest event_date object (a theater play can have several, a book only one) to tell whether the event is current, past or future: SELECT s.id_event_su

Re: [SQL] dynamic events categorization

2008-06-27 Thread Louis-David Mitterrand
On Thu, Jun 26, 2008 at 05:06:14PM +0200, Marc Mamin wrote: > > Hello, Hi Marc, > I guess that the time offsets (now-21 and now-28) are evaluated each > time the corresponding condition is met. Excellent suggestion, this makes the query ~ 15% faster. Every bit counts. > It may be faster to put

Re: [SQL] Re: Efficiently determining the number of bits set in the contents of, a VARBIT field

2008-07-27 Thread Jean-David Beyer
. >> >> Allan. > > When I had to do that, in days with smaller amounts of RAM, but very long bit-vectors, I used a faster function sort-of like this: static char table[256] = { 0,1,1,2,1,2,2,3,1,. }; Then like above, but instead of the loop, n+= table[aval]; You get

[SQL] exclusion query

2008-09-22 Thread Louis-David Mitterrand
Hi, I've got five related tables: - person_type: id_person_type integer type_fr text - person: id_person integer ... - person_to_event: id_person -> person id_person_type -> person_type (e.g: actor, di

Re: [SQL] exclusion query

2008-09-22 Thread Louis-David Mitterrand
On Mon, Sep 22, 2008 at 04:34:14PM +0200, Louis-David Mitterrand wrote: > Hi, > > I've got five related tables: > > - person_type: > id_person_type integer > type_fr text > > - person: > id_person integer

Re: [SQL] exclusion query

2008-09-23 Thread Louis-David Mitterrand
On Mon, Sep 22, 2008 at 09:39:08AM -0700, Mark Roberts wrote: > > Taking your second email into account, I came up with: > > select distinct pt.type_fr > from person_to_event pte > inner join person_type using (id_person_type) > where id_person_type in ( > select id_person_type > from

Re: [SQL] exclusion query

2008-09-25 Thread Louis-David Mitterrand
On Thu, Sep 25, 2008 at 02:11:23PM +0100, Oliveiros Cristina wrote: > Hi, Louis-David, > > I guess you already have your problem solved, but just for the sake of > curiosity, another > way to do it might be to tweak a little your original query, I've written > on Capital

[SQL] many-to-many relationship

2008-10-06 Thread Louis-David Mitterrand
Hi, Say you have several objects (tables): person, location, event, etc. all of which can have several images attached. What is the best way to manage relations between a single 'image' table and these different objects? For now each 'image' row has pointers to id_person, id_location, id_event,

Re: [SQL] many-to-many relationship

2008-10-06 Thread Louis-David Mitterrand
On Mon, Oct 06, 2008 at 09:25:09AM -0400, Dan McFadyen wrote: > Hello, > > Simplest way I can think of is create 3 relation tables, a person/image > table, location/image table and event/image table. > > Each is just made up for 2 foreign keys to the first ID and image ID, > using both as the PK

Re: [SQL] many-to-many relationship

2008-10-08 Thread Louis-David Mitterrand
On Tue, Oct 07, 2008 at 05:16:39PM -0700, Steve Midgley wrote: > > I think the relationship tables method works pretty well but I have > another suggestion. You could store the Foreign table name within image > table as well as the Foreign key. > > |id|image_url|f_table|f_key > |1 |url..|pe

[SQL] adding "order by" to a "group by" query

2008-12-06 Thread Louis-David Mitterrand
Hi, This query: select p.id_person, person_name(p), array_accum(distinct pt.type_fr) from person p left join person_to_event x using (id_person) left join person_type pt using (id_person_type) where person_name(p) ilike '%wil

Re: [SQL] adding "order by" to a "group by" query

2008-12-06 Thread Louis-David Mitterrand
On Sat, Dec 06, 2008 at 06:26:06PM +0100, Andreas Kretschmer wrote: > Louis-David Mitterrand <[EMAIL PROTECTED]> schrieb: > > > > But if I append this > > > > order by pt.type_fr = 'comédien'; > > > > I get this error: > > &g

Re: [SQL] adding "order by" to a "group by" query

2008-12-06 Thread Louis-David Mitterrand
On Sat, Dec 06, 2008 at 06:24:25PM +, John Lister wrote: > >(still curious about the "must be used in an aggregate function" error > >though... because I do use it in an aggregate) > > You're original query grouped on the person id and name, therefore you > can only return (and order by) thes

[SQL] optimizing a query

2008-12-14 Thread Louis-David Mitterrand
Hi, I have an 'event' table and an 'event_date' table pointing to it containing (potentially) several event dates (start and (optionnaly) end) for the event in the past, present and future. I'm trying to build a query to select the most "relevant" date: 'current' or 'next' or 'last' (by order of

Re: [SQL] optimizing a query

2008-12-14 Thread Louis-David Mitterrand
On Sun, Dec 14, 2008 at 02:51:24PM -0800, Michal Szymanski wrote: > On 14 Gru, 20:22, vindex+lists-pgsql-...@apartia.org (Louis-David > Mitterrand) wrote: > > > > I have an 'event' table and an 'event_date' table pointing to it > > containing

[SQL] archiving or versioning data?

2008-12-16 Thread Louis-David Mitterrand
Hi, I'd like to find a way to archive versions of my data in an elegant and extensible way. When a user modifies certain entries I'd like the database to keep the previous versions (or a limited, definable number of versions). Wiki-style. Would that be a good use of postgres' arrays? So I'm lo

[SQL] using max() aggregate

2000-06-15 Thread Louis-David Mitterrand
sdfsdfsdfsdf | 2001-04-10 15:00:00+02 (3 rows) But the problem is that I now get three rows when I only want the max() item. How should I do it? Thanks in advance, -- Louis-David Mitterrand - [EMAIL PROTECTED] - http://www.apartia.fr "Logiciels libres : nourris au code source sans f

Re: Antw: [SQL] using max() aggregate

2000-06-16 Thread Louis-David Mitterrand
sing: SELECT title,stopdate FROM auction ORDER BY stopdate LIMIT 1; which seems the best solution (I was a bit concerned about performance, but then again the max() aggregate does a scan of all rows as well). Cheers, -- Louis-David Mitterrand - [EMAIL PROTECTED] - http://www.apartia.fr This is Linux Country. On a quiet night you can hear Windows NT reboot.

Re: Antw: [SQL] using max() aggregate

2000-06-16 Thread Louis-David Mitterrand
then if you omit the clause from the outer select you risk having a false match if two records have the same stopdate: SELECT title,login,stopdate FROM auction WHERE stopdate = (SELECT max(stopdate) FROM auction WHERE login LIKE 'm%'); > Tom's solution has the drawback, tha

[SQL] finding (and recycling) holes in sequences

2000-06-25 Thread Louis-David Mitterrand
for a "standard" way of doing this if such a thing exists. TIA -- Louis-David Mitterrand - [EMAIL PROTECTED] - http://www.apartia.fr "For a list of the ways which technology has failed to improve our quality of life, press 3."

Re: [SQL] Time Aggregates

2000-08-02 Thread David Lloyd-Jones
"Thomas Lockhart" <[EMAIL PROTECTED]> replied to: "Itai Zukerman" <[EMAIL PROTECTED]> > > I'm currently doing this: > > SELECT symbol, date_trunc('minute', posted), > > min(price), max(price), avg(price) > > FROM trade > > GROUP BY symbol, date_trunc('minute', posted); > > to get a

[SQL] Week of the Year?

2000-08-11 Thread David Lloyd-Jones
I'm probably staring right at it. (One of the difficulties with RTFMing, is having too many docs!) Is there anything in the API that produces the week of the year, from 1 to 52 or 53 depending on the week of the year, and the days that are in that week? Many thanks.

Re: [SQL] Week of the Year?

2000-08-11 Thread David Lloyd-Jones
Got it: -U with date. -dlj. - Original Message - From: "David Lloyd-Jones" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, August 11, 2000 9:27 PM Subject: [SQL] Week of the Year? > I'm probably staring right at it.

[SQL]

2001-01-26 Thread David J. R. Brook
gestions? (I get the same problem with the varbit data type) David Brook Asst. Professor, Department of Chemistry and Biochemistry University of Detroit Mercy ph: (313) 993-2495 fax: (313) 993-1144David Brook Asst. Professor, Department of Chemistry and Bioc

<    1   2   3   4   5