Re: [SQL] Trimming the cost of ORDER BY in a simple query

2005-05-02 Thread Mischa Sandberg
Quoting [EMAIL PROTECTED]: > I have a simple query with a pretty high cost (EXPLAIN ...), and I'm > wondering if I can somehow trim it. > > Query (shows the last 7 dates): > > => SELECT DISTINCT date_part('year', uu.add_date), > date_part('month', > uu.add_date), date_part('day', u

[SQL] Trimming the cost of ORDER BY in a simple query

2005-05-02 Thread ogjunk-pgjedan
Hello, I have a simple query with a pretty high cost (EXPLAIN ...), and I'm wondering if I can somehow trim it. Query (shows the last 7 dates): => SELECT DISTINCT date_part('year', uu.add_date), date_part('month', uu.add_date), date_part('day', uu.add_date) FROM user_url uu WHERE uu.user_

Re: [SQL] [ANNOUNCE] pgtop, display PostgreSQL processes in `top' style

2005-05-02 Thread Markus Schaber
Hi, Cosimo, Cosimo Streppone wrote: > 1) is it possible to know Pg backend uptime with >SQL queries? Or must I look at postmaster.pid file? >or even something else? In contrib, there's a function caled backend_pid() defined in misc_utils.sql, it may be helpful for you. markus signatur

Re: [SQL] Function or Field?

2005-05-02 Thread Joel Fradkin
You could also make a table with just that data in it so you don't have the field in all the records and you don't have to check all the records to see what is next. I am assuming this is some kind of a flag values used in a batch, if you just need the last id I use max(id)+1. Joel Fradkin Waza

[SQL] Function or Field?

2005-05-02 Thread lucas
Hi. What is the better way to store the last record for a translation??? I.E: The data for the last product vendding. What is better: a) Create a field in "product" table and create a Trigger (before insert or update into vendding table) to alter this field. b) Create a view or function that ch

Re: [SQL] Record Log Trigger

2005-05-02 Thread CHRIS HOOVER
One change you might want to look at is not using the now() function. According to the docs, the now() function always returns the start of the transaction time. So, if your code is using transaction blocks, the time may not be what you are expecting. This is what I had do to in my trigger to get

[SQL] Record Log Trigger

2005-05-02 Thread lucas
Hi all, I am building a database in postgresql and I made a function that returns the system time and the current user... like this: CREATE OR REPLACE FUNCTION generate_idx() returns text as $$ select to_char(now(),'MMDDHHMISSUSTZ')||CURRENT_USER; $$ language 'SQL'; CREATE OR REPLACE FUNC

[SQL] odd error

2005-05-02 Thread Joel Fradkin
I am getting an odd error. Same data loaded on windows does not give it and even going from a client over VLAN does not give it, so I am guessing it is based on timing or something. Microsoft Cursor Engine error '80004005' Data provider or other service returned an E_FAIL status. /app

Re: [despammed] [SQL] Query two database at once

2005-05-02 Thread Andreas Kretschmer
am 02.05.2005, um 17:36:05 +0200 mailte Stéphane RIFF folgendes: > Hi, > > I want to ewecute a query on two database like this : > > SELECT * FROM table01 T1, table02 T2 WHERE T1.gid=T2.gid AND > T2.my_field='".$value."' > > The problem is that table01 is in a different database than table02 a

Re: [SQL] Java and Currval

2005-05-02 Thread Bruno Wolff III
On Mon, May 02, 2005 at 17:30:12 +0100, Sam Adams <[EMAIL PROTECTED]> wrote: > I'm having trouble getting the currval function to work from a Java > program (or from Postgres at all). I want to get the value of addressid > in the table taddress. The best I seem to be able to come up with is > 'SE

Re: [SQL] Java and Currval

2005-05-02 Thread Volkan YAZICI
Hi, On 5/2/05, Sam Adams <[EMAIL PROTECTED]> wrote: > I'm having trouble getting the currval function to work from a Java > program (or from Postgres at all). I want to get the value of addressid > in the table taddress. The best I seem to be able to come up with is > 'SELECT currval(taddress.addr

Re: [SQL] Java and Currval

2005-05-02 Thread Michael Fuhr
On Mon, May 02, 2005 at 05:30:12PM +0100, Sam Adams wrote: > > I'm having trouble getting the currval function to work from a Java > program (or from Postgres at all). I want to get the value of addressid > in the table taddress. The best I seem to be able to come up with is > 'SELECT currval(taddr

[SQL] Java and Currval

2005-05-02 Thread Sam Adams
I'm having trouble getting the currval function to work from a Java program (or from Postgres at all). I want to get the value of addressid in the table taddress. The best I seem to be able to come up with is 'SELECT currval(taddress.addressid)'. However this gives me the error 'ERROR: relation "1

[SQL] Query two database at once

2005-05-02 Thread Stéphane RIFF
Hi, I want to ewecute a query on two database like this : SELECT * FROM table01 T1, table02 T2 WHERE T1.gid=T2.gid AND T2.my_field='".$value."' The problem is that table01 is in a different database than table02 and i don't know how to telle postgresql to look in two db. Is there a solution othe

Re: [SQL] how many tuples on a cursor?

2005-05-02 Thread Christoph Haller
Tom Lane wrote: > > Christoph Haller <[EMAIL PROTECTED]> writes: > > What else seems to work is MOVE 2147483647 > > (INT_MAX) and then get the max number of rows > > by PQcmdTuples(). > > I'd suggest "MOVE FORWARD ALL" rather than hard-wiring assumptions > about the maximum possible value of infi

Re: [SQL] how many tuples on a cursor?

2005-05-02 Thread Tom Lane
Christoph Haller <[EMAIL PROTECTED]> writes: > What else seems to work is MOVE 2147483647 > (INT_MAX) and then get the max number of rows > by PQcmdTuples(). I'd suggest "MOVE FORWARD ALL" rather than hard-wiring assumptions about the maximum possible value of infinity ;-) > But I have no idea

Re: [SQL] how many tuples on a cursor?

2005-05-02 Thread Christoph Haller
Andreas Kretschmer wrote: > > Hello, > > I want to know how many tuples there on a cursor, and i found > http://groups.google.de/groups?hl=de&lr=&threadm=3ACA7BB0.7020106%402cactus.com&rnum=7&prev=/groups%3Fhl%3Dde%26lr%3D%26q%3Dpostgres%2Bcursor%2Bcount%26btnG%3DSuche > > But, this posting is v

Re: [SQL] trigger/rule question

2005-05-02 Thread Christoph Haller
Enrico Weigelt wrote: > > * Christoph Haller <[EMAIL PROTECTED]> wrote: > > Hi, > > > I assume this still refers to > > [SQL] RULE for mtime recording > > from last Friday. > > ehm, yeah. I forgot that I've already asked this stuff ... > hmmpf. seems I'm not getting younger ;-) > > > > I gave

[SQL] how many tuples on a cursor?

2005-05-02 Thread Andreas Kretschmer
Hello, I want to know how many tuples there on a cursor, and i found http://groups.google.de/groups?hl=de&lr=&threadm=3ACA7BB0.7020106%402cactus.com&rnum=7&prev=/groups%3Fhl%3Dde%26lr%3D%26q%3Dpostgres%2Bcursor%2Bcount%26btnG%3DSuche But, this posting is very old (2001-04-03), i'm using 7.4.6.