Re: [SQL] Slow Query problem

2008-01-29 Thread Premsun Choltanwanich
SQL I use for create related table and view:     CREATE TABLE t_payment_detail(  "sysid" bigserial NOT NULL,  receiptno varchar(10) NOT NULL,  refpath varchar(255) NOT NULL,  refno varchar(100) NOT NULL,  CONSTRAINT t_payment_detail_pkey PRIMARY KEY ("sysid")) WITHOUT OIDS;   CREATE TABLE t_recei

Re: [SQL] Slow Query problem

2008-01-29 Thread Premsun Choltanwanich
SQL I use for create related table and view:     CREATE TABLE t_payment_detail(  "sysid" bigserial NOT NULL,  receiptno varchar(10) NOT NULL,  refpath varchar(255) NOT NULL,  refno varchar(100) NOT NULL,  CONSTRAINT t_payment_detail_pkey PRIMARY KEY ("sysid")) WITHOUT OIDS;   CREATE TABLE t_recei

Re: [SQL] Slow Query problem

2008-01-29 Thread Andreas Joseph Krogh
On Tuesday 29 January 2008 09:18:00 Premsun Choltanwanich wrote: > I already install the latest version of PostgreSQL on my machine then try > again. I found that it has a little improvement about 0.5 second but I > think it still slow. > > What is the 'more detail' you need? Your tables, views an

Re: [SQL] Slow Query problem

2008-01-29 Thread Premsun Choltanwanich
I already install the latest version of PostgreSQL on my machine then try again. I found that it has a little improvement about 0.5 second but I think it still slow.   What is the 'more detail' you need?   Any other advise?       >>> Tom Lane <[EMAIL PROTECTED]> 1/29/2008 0:20 >>>Andreas Joseph K

Re: [SQL] Slow Query problem

2008-01-28 Thread Tom Lane
Andreas Joseph Krogh <[EMAIL PROTECTED]> writes: > On Monday 28 January 2008 08:18:24 Premsun Choltanwanich wrote: >> I am currently using PostgreSQL database version 8.0.13. My problem >> relates to a slow result when a query using a defined view joins to another >> table for a result. > It is v

Re: [SQL] Slow Query problem

2008-01-28 Thread Andreas Joseph Krogh
On Monday 28 January 2008 08:18:24 Premsun Choltanwanich wrote: > Dear All, > > I am currently using PostgreSQL database version 8.0.13. My problem > relates to a slow result when a query using a defined view joins to another > table for a result. > > Background: I have 7 tables of invoice transa

[SQL] Slow Query problem

2008-01-27 Thread Premsun Choltanwanich
Dear All, I am currently using PostgreSQL database version 8.0.13.  My problem relates to a slow result when a query using a defined view joins to another table for a result. Background:  I have 7 tables of invoice transactions.  The tables are slightly different in that they record different dat

Re: [SQL] slow query - only uses indices

2007-12-24 Thread Pavel Stehule
Hello there is some differences: ndex Scan using i_tablea_atextfield on tablea ru (cost= 0.00..2265.28 rows=2 width=12) (actual time=0.624..881.313 rows=228 loops=1) Index Cond: (atextfield = 'thelookupval'::text) Filter: ((achar1fi

Re: [SQL] slow query - only uses indices

2007-12-24 Thread imad
On Dec 24, 2007 7:46 PM, Marc <[EMAIL PROTECTED]> wrote: > Hey Folks, > > This query is running really slowly. Sometimes much slower then others. I > have a feeling that there may be contention on one of the indices it is > using. In the explain plan, it looks like it estimates 2 rows but actual

[SQL] slow query - only uses indices

2007-12-24 Thread Marc
Hey Folks, This query is running really slowly. Sometimes much slower then others. I have a feeling that there may be contention on one of the indices it is using. In the explain plan, it looks like it estimates 2 rows but actually finds 228 rows? Is that really bad? Query and explain plan a

Re: [SQL] slow query execution

2007-05-31 Thread Richard Huxton
Trigve Siver wrote: - Original Message From: Richard Huxton <[EMAIL PROTECTED]> To: Trigve Siver <[EMAIL PROTECTED]> Sent: Thursday, May 31, 2007 10:33:40 AM Subject: Re: [SQL] slow query execution So - you want something like: The user runs a query ("all blue things

Re: [SQL] slow query execution

2007-05-31 Thread Trigve Siver
Thanks for reply, This solution looks promising. I'll look at it and test it and let you know. Thanks once more Trigve - Original Message From: Richard Huxton <[EMAIL PROTECTED]> To: Trigve Siver <[EMAIL PROTECTED]> Sent: Thursday, May 31, 2007 10:33:40 AM Subjec

Re: [SQL] slow query execution

2007-05-31 Thread Bart Degryse
Sorry, I don't know C++ enough to help you much. I also don't understand your problem well enough. >>> Trigve Siver <[EMAIL PROTECTED]> 2007-05-31 9:46 >>> Hi, thanks for reply No, I'm working with c++ and libpqxx (pgsql c++ binding). I'm using Win32 Listview control with LS_OWNERDATA style. I

Re: [SQL] slow query execution

2007-05-31 Thread Trigve Siver
out 10.000+ records and user want to view/search only first 100 records. thanks Trigve - Original Message From: Bart Degryse <[EMAIL PROTECTED]> To: pgsql-sql@postgresql.org Sent: Thursday, May 31, 2007 9:24:04 AM Subject: Re: [SQL] slow query execution Am I right in assuming tha

Re: [SQL] slow query execution

2007-05-31 Thread Bart Degryse
in the listview. >>> Trigve Siver <[EMAIL PROTECTED]> 2007-05-30 21:11 >>> >- Original Message >From: Richard Huxton <[EMAIL PROTECTED]> >To: Trigve Siver <[EMAIL PROTECTED]> >Cc: pgsql-sql@postgresql.org >Sent: Wednesday, May 30, 2007 9:05:09

Re: [SQL] slow query execution

2007-05-30 Thread Trigve Siver
>- Original Message >From: Richard Huxton <[EMAIL PROTECTED]> >To: Trigve Siver <[EMAIL PROTECTED]> >Cc: pgsql-sql@postgresql.org >Sent: Wednesday, May 30, 2007 9:05:09 PM >Subject: Re: [SQL] slow query execution > >Trigve Siver wrote: >> >&g

Re: [SQL] slow query execution

2007-05-30 Thread Richard Huxton
Trigve Siver wrote: I seee...when new data will be added to table, then row numbers wouldn''t be valid anymore. Hmmm...looked like I need to find other solution. Try explaining what it is you're trying to achieve, and maybe someone will be able to suggest a solution. -- Richard Huxton

Re: [SQL] slow query execution

2007-05-30 Thread Trigve Siver
>- Original Message >From: Andrew Sullivan <[EMAIL PROTECTED]> >To: pgsql-sql@postgresql.org >Sent: Wednesday, May 30, 2007 8:30:32 PM >Subject: Re: [SQL] slow query execution > >On Wed, May 30, 2007 at 11:08:02AM -0700, Trigve Siver wrote: > >> I wan

Re: [SQL] slow query execution

2007-05-30 Thread Andrew Sullivan
On Wed, May 30, 2007 at 11:08:02AM -0700, Trigve Siver wrote: > I want to do it only for some queries. So when I need query like > that "SELECT * from t1" I need to add row_numbers there. So I will > have "query with row_numbers" (where row_numbers are row numbers of > my virtual list view). Then

Re: [SQL] slow query execution

2007-05-30 Thread Trigve Siver
>- Original Message >From: Andrew Sullivan <[EMAIL PROTECTED]> >To: pgsql-sql@postgresql.org >Sent: Wednesday, May 30, 2007 7:39:18 PM >Subject: Re: [SQL] slow query execution > >On Wed, May 30, 2007 at 10:03:16AM -0700, Trigve Siver wrote: >> Hi, Thanks f

Re: [SQL] slow query execution

2007-05-30 Thread Andrew Sullivan
On Wed, May 30, 2007 at 10:03:16AM -0700, Trigve Siver wrote: > Hi, Thanks for reply, As you have mentioned I need to get row > numbers for my query, so when I make some other query with same > data I will know which row number has a particular ID. Oh, wait. If _that's_ your plan, then this will

Re: [SQL] slow query execution

2007-05-30 Thread Trigve Siver
Thanks a lot Trigve - Original Message From: Rodrigo De León <[EMAIL PROTECTED]> To: pgsql-sql@postgresql.org; Trigve Siver <[EMAIL PROTECTED]> Sent: Wednesday, May 30, 2007 7:28:47 PM Subject: Re: [SQL] slow query execution On 5/30/07, Trigve Siver <[EMAIL PROTECTED]>

Re: [SQL] slow query execution

2007-05-30 Thread Rodrigo De León
On 5/30/07, Trigve Siver <[EMAIL PROTECTED]> wrote: Can you point me to some sources or give me some examples, please? CREATE OR REPLACE FUNCTION ROWNUM() RETURNS BIGINT AS $$ BEGIN RETURN NEXTVAL('ROWNUM_SEQ'); EXCEPTION WHEN OTHERS THEN CREATE T

Re: [SQL] slow query execution

2007-05-30 Thread Trigve Siver
e to some sources or give me some examples, please? Thanks Trigve - Original Message From: Andrew Sullivan <[EMAIL PROTECTED]> To: pgsql-sql@postgresql.org Sent: Wednesday, May 30, 2007 6:45:53 PM Subject: Re: [SQL] slow query execution On Wed, May 30, 2007 at 08:56:45AM -07

Re: [SQL] slow query execution

2007-05-30 Thread Andrew Sullivan
On Wed, May 30, 2007 at 08:56:45AM -0700, Trigve Siver wrote: > Hi all, > > This query executes very slow: > > select (select count(*) from customer where id <= a.id) as row, id, > from customer as a order by id; So you are trying to get the ordinal position of every ID in the table? I'm not su

[SQL] slow query execution

2007-05-30 Thread Trigve Siver
Hi all, This query executes very slow: select (select count(*) from customer where id <= a.id) as row, id, from customer as a order by id; Where customer has id column and others and has also index on id column. The table has about 10.000+ records. When used with "explain", it gives me this o

Re: [SQL] slow query

2007-04-05 Thread Andrew Sullivan
On Thu, Apr 05, 2007 at 01:47:03AM -0400, Tom Lane wrote: > [ shrug... ] If the damage is already done, lazy VACUUM won't fix it. > Also, if there are enough open transactions at any one time and sufficient churn in the table, lazy VACUUM may not be able to keep up. (We had that experience with

Re: [SQL] slow query

2007-04-05 Thread Tom Lane
"A. Kretschmer" <[EMAIL PROTECTED]> writes: > am Thu, dem 05.04.2007, um 1:27:25 -0400 mailte Tom Lane folgendes: >> I'm betting the problem is poor vacuuming practice leading to lots of >> dead space. There's no way it takes 22 sec to read 10 rows if the >> table is reasonably dense. > This wa

Re: [SQL] slow query

2007-04-04 Thread A. Kretschmer
am Thu, dem 05.04.2007, um 1:27:25 -0400 mailte Tom Lane folgendes: > "A. Kretschmer" <[EMAIL PROTECTED]> writes: > > am Wed, dem 04.04.2007, um 23:17:54 -0400 mailte Sumeet folgendes: > >> sm=> explain analyze select * from ma limit 10; > >> QUERY > >> PLAN

Re: [SQL] slow query

2007-04-04 Thread Tom Lane
"A. Kretschmer" <[EMAIL PROTECTED]> writes: > am Wed, dem 04.04.2007, um 23:17:54 -0400 mailte Sumeet folgendes: >> sm=> explain analyze select * from ma limit 10; >> QUERY >> PLAN >> -

Re: [SQL] slow query

2007-04-04 Thread A. Kretschmer
am Wed, dem 04.04.2007, um 23:17:54 -0400 mailte Sumeet folgendes: > sm=> explain analyze select * from ma limit 10; > QUERY > PLAN > --

[SQL] slow query

2007-04-04 Thread Sumeet
Hi all I ran a simple query like the one displayed below and it takes a lot of time to execute on this table. This table has 48 million recordsand i worry about this table a lot coz i need to perform join on this table with some other table having around 13 million recordsI've tried vacuu

Re: [SQL] Slow query - SELECTing one row from 'big' table.

2005-11-03 Thread Tom Lane
Mario Splivalo <[EMAIL PROTECTED]> writes: > SELECT * > FROM messages > WHERE (id = currval(''public.message_id_seq''::text)) That cannot legally be converted into an indexscan, because currval() is a volatile function --- the planner cannot be certain that its value won

[SQL] Slow query - SELECTing one row from 'big' table.

2005-11-03 Thread Mario Splivalo
I have a procedure that goes something like this: -- Function: create_message(varchar, varchar, varchar, int4) -- DROP FUNCTION create_message("varchar", "varchar", "varchar", int4); CREATE OR REPLACE FUNCTION create_message("varchar", "varchar", "varchar", int4) RETURNS SETOF messages AS ' DECL

Re: [SQL] slow query

2003-07-23 Thread Markus Bertheau
I've forgotten to put data for the belegungen table in the test data set, I've corrected that now, an updated data set is available at the same URL: http://www.bab24.de/media/testdata.sql -- Markus Bertheau Cenes Data GmbH ---(end of broadcast)---

Re: [SQL] slow query

2003-07-22 Thread Markus Bertheau
I'm trying to explain the bigger function a bit although it's only called in 2% of the cases. В Втр, 22.07.2003, в 19:07, Markus Bertheau пишет: > CREATE FUNCTION iGetNumOfBookedRes(integer, timestamp, timestamp) RETURNS numeric AS > ' > SELECT > CASE WHEN (MAX(kumulierte) IS NULL) THEN 0 E

[SQL] slow query

2003-07-22 Thread Markus Bertheau
Hi, we have this large query about which we want to know if it can be made faster. The query is: select * from ( select ressourcen.*, gebaeude.bezeichnung as "gebaeude.bezeichnung", gebaeude.gebaeude_id as "gebaeude.gebaeude_id", gebaeude.kurzbezeichnung as "gebaeude.kurzbezeichnu

Re: [SQL] Slow query

2003-01-23 Thread Tomasz Myrta
Ricardo Javier Aranibar León wrote: I run Explain and this is the result: EXPLAIN SELECT * from simon where fecha='20030122' order by hora desc; NOTICE: QUERY PLAN: Sort (cost=57700.73..57700.73 rows=23682 width=46) -> Seq Scan on simon (cost=0.00..55591.05 rows=23682 width=46) and when I ru

[SQL] Slow query

2003-01-23 Thread Ricardo Javier Aranibar León
Hi List, I need your help, I don't know what happend with my queries when I use this table "simon".When I like display the result the query is very slow and take five minutes or more. The number of registers in simon is:2421580 and the other table "llamada" the number of registers is :1779741 b