pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
problems with postgresql speed
7+ messages / 7 participants
[nested] [flat]

* problems with postgresql speed
@ 2001-12-03 10:14  Manuel Trujillo <manueltrujillo@dorna.es>
  0 siblings, 2 replies; 7+ messages in thread

From: Manuel Trujillo @ 2001-12-03 10:14 UTC (permalink / raw)
  To: pgsql-admin

Hi.

I've serious problems with the speed of my database.
If I execute any query like this;

SELECT d.gallery_id, e.subevent_id, d.result_type_id,
d.result_type_name, e.language_id FROM ((SELECT b.gallery_id,
b.element_id AS result_type_id, c.name AS result_type_name FROM
gallery_element b, result_type c WHERE ((c.id = b.element_id) AND
(b.element_type_id = 10))) d JOIN (SELECT b.gallery_id, b.element_id AS
subevent_id, c.language_id FROM gallery_element b, view_subevent_info c
WHERE ((c.subevent_id = b.element_id) AND (b.element_type_id = 9))) e ON
((d.gallery_id = e.gallery_id)));

The result take a minute, or more, to show the results.
The postgresql.conf I used is attached to this e-mail.
The table "gallery_element" have 8644 rows, and it have got 25932
registers.
The machine has 512 Mb RAM and 1.4 PIV processor.

Thank you very much.

-- 
Manuel Trujillo         manueltrujillo@dorna.es
Technical Engineer      http://www.motograndprix.com
Dorna Sports S.L.       +34 93 4702864

Attachments:

postgresql.conf (text/plain, 3.1K) download # # PostgreSQL configuration file # ----------------------------- # # This file consists of lines of the form # # name = value # # (The `=' is optional.) White space is collapsed, comments are # introduced by `#' anywhere on a line. The complete list of option # names and allowed values can be found in the PostgreSQL # documentation. Examples are: #log_connections = on #fsync = off #max_connections = 64 # Any option can also be given as a command line switch to the # postmaster, e.g., 'postmaster -c log_connections=on'. Some options # can be set at run-time with the 'SET' SQL command. #======================================================================== # # Connection Parameters # tcpip_socket = true #ssl = false max_connections = 64 # 1-1024 #port = 5432 #hostname_lookup = false #show_source_port = false #unix_socket_directory = '' #unix_socket_group = '' #unix_socket_permissions = 0777 #virtual_host = '' #krb_server_keyfile = '' # # Performance # sort_mem = 1024 shared_buffers = 2048 #2*max_connections # min 16 #fsync = true # # Optimizer Parameters # enable_seqscan = false enable_indexscan = false enable_tidscan = false enable_sort = false enable_nestloop = false enable_mergejoin = false enable_hashjoin = false ksqo = false geqo = true effective_cache_size = 6000 # default in 8k pages random_page_cost = 2 cpu_tuple_cost = 0.05 cpu_index_tuple_cost = 0.005 cpu_operator_cost = 0.0025 geqo_selection_bias = 1.5 # range 1.5-2.0 geqo_effort = 50.0 geqo_pool_size = 256 geqo_generations = 0 geqo_random_seed = 1 # # GEQO Optimizer Parameters # geqo_threshold = 17 geqo_pool_size = 0 #default based in tables, range 128-1024 geqo_effort = 1 geqo_generations = 0 geqo_random_seed = -1 # auto-compute seed # # Inheritance # #sql_inheritance = true # # Deadlock # #deadlock_timeout = 1000 # # Expression Depth Limitation # #max_expr_depth = 10000 # min 10 # # Write-ahead log (WAL) # wal_buffers = 8 # min 4 wal_files = 0 # range 0-64 wal_sync_method = fsync # fsync or fdatasync or open_sync or open_datasync # Note: default wal_sync_method varies across platforms wal_debug = 0 # range 0-16 commit_delay = 0 # range 0-100000 commit_siblings = 5 # range 1-1000 checkpoint_segments = 3 # in logfile segments (16MB each), min 1 checkpoint_timeout = 300 # in seconds, range 30-3600 # # Debug display # #silent_mode = false log_connections = true log_timestamp = true log_pid = true debug_level = 2 # range 0-16 #debug_print_query = false #debug_print_parse = false #debug_print_rewritten = false #debug_print_plan = false #debug_pretty_print = false #ifdef USE_ASSERT_CHECKING #debug_assertions = true #endif # # Syslog # #ifdef ENABLE_SYSLOG syslog = 1 # range 0-2 syslog_facility = 'LOCAL0' syslog_ident = 'postgres' #endif # # Statistics # #show_parser_stats = false #show_planner_stats = false #show_executor_stats = false #show_query_stats = false #ifdef BTREE_BUILD_STATS #show_btree_build_stats = false #endif # # Lock Tracing # #trace_notify = false #ifdef LOCK_DEBUG #trace_locks = false #trace_userlocks = false #trace_spinlocks = false #debug_deadlocks = false #trace_lock_oidmin = 16384 #trace_lock_table = 0 #endif
^ permalink raw reply [nested|flat] 7+ messages in thread

* Re: problems with postgresql speed
@ 2001-12-03 12:10  Stephan Szabo <sszabo@megazone23.bigpanda.com>
  parent: Manuel Trujillo <manueltrujillo@dorna.es>
  1 sibling, 0 replies; 7+ messages in thread

From: Stephan Szabo @ 2001-12-03 12:10 UTC (permalink / raw)
  To: Manuel Trujillo <manueltrujillo@dorna.es>; +Cc: pgsql-admin

On Mon, 3 Dec 2001, Manuel Trujillo wrote:

> I've serious problems with the speed of my database.
> If I execute any query like this;
>
> SELECT d.gallery_id, e.subevent_id, d.result_type_id,
> d.result_type_name, e.language_id FROM ((SELECT b.gallery_id,
> b.element_id AS result_type_id, c.name AS result_type_name FROM
> gallery_element b, result_type c WHERE ((c.id = b.element_id) AND
> (b.element_type_id = 10))) d JOIN (SELECT b.gallery_id, b.element_id AS
> subevent_id, c.language_id FROM gallery_element b, view_subevent_info c
> WHERE ((c.subevent_id = b.element_id) AND (b.element_type_id = 9))) e ON
> ((d.gallery_id = e.gallery_id)));
>
> The result take a minute, or more, to show the results.
> The postgresql.conf I used is attached to this e-mail.
> The table "gallery_element" have 8644 rows, and it have got 25932
> registers.
> The machine has 512 Mb RAM and 1.4 PIV processor.

Have you run vacuum analyze recently on the database?
Can you send the schema for the tables/views involved and the
explain output?




^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: problems with postgresql speed
@ 2001-12-03 12:30  Ludva Radomír (KM) <Radomir.Ludva@cssz.cz>
  0 siblings, 2 replies; 7+ messages in thread

From: Ludva Radomír (KM) @ 2001-12-03 12:30 UTC (permalink / raw)
  To: pgsql-admin

I have got the same problem.
I am working on it about a month :(.
It is not hot :-)

Two machines:
1. Pentium3 400Mhz, hdd 8Gb, 64Mb RAM, kernel 2.2.14-5.0 (RedHat 6.2)
2. Celeron  400Mhz, hdd 8Gb, 64Mb RAM, kernel 2.2.14-5.0 (RedHat 6.2)

The same database, the same postgres Version 7.1.3, the same configuration.
Only processor is diferent, ...

Queryes from client application on Windows over ODBC:
1. 40sec.
2. 90sec.

Radmi

---
Odchozí zpráva neobsahuje viry.
Zkontrolováno antivirovým systémem AVG (http://www.grisoft.cz).
Verze: 6.0.303 / Virová báze: 164 - datum vydání: 24.11.2001



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* FW: problems with postgresql speed
@ 2001-12-03 12:53  Arguile <arguile@lucentstudios.com>
  0 siblings, 0 replies; 7+ messages in thread

From: Arguile @ 2001-12-03 12:53 UTC (permalink / raw)
  To: pgsql-admin

Manuel wrote:
>
> Hi.
>
> I've serious problems with the speed of my database.
> If I execute any query like this;
>
[big ugly query :]


Yes I'd say so, that's a rather horrendous query. You're a better computer
than I if you can make heads or tails of it :). So I ran it through an SQL
tidier and massaged it a bit.

SELECT   d.gallery_id, e.subevent_id, d.result_type_id,
         d.result_type_name, e.language_id
FROM     (
            SELECT   g.gallery_id, g.element_id AS result_type_id,
                     r.name AS result_type_name
            FROM     gallery_element g, result_type r
            WHERE    r.id = g.element_id
              AND    g.element_type_id = 10
         ) d
         JOIN
         (
            SELECT   g.gallery_id, g.element_id AS subevent_id,
                     v.language_id
            FROM     gallery_element g, view_subevent_info v
            WHERE    v.subevent_id = g.element_id
              AND    g.element_type_id = 9
         ) e
         ON d.gallery_id = e.gallery_id;

A few suggestions:

- I get the feeling the table are't very normalised. I could be wrong but
the fact your combining two records from the same table (using subtables)
into one 'seems' odd.

- A self join might be a better fit in this case, and probably much less
expensive than the subqueries.

- As stated the subtables are going to be very expensive, use EXAMINE (see
manual) to check which pieces are worst and try optimising there first.

- Join using a WHERE a.pk = b.fk syntax to let Pg's engine optimise (general
rule).

- 'view_subevent_info' I'm guessing this is a VIEW (for obvious reasons).
You use only a single field from it, depending on the views complexity you
could be adding tons of work. Maybe get it from the source table.

- Possibly make this query a view or even a temp/cache table if it's called
often.

I'm disinclined to think Pg is the most limiting factor in this, especially
as the query looks to be generated by drag and drop tool. A bit of human
mucking about with the SQL might yield better results.



Also check out Bruce Momjian chapters on performance tuning (a great
purchase).

Perfomance
http://www.ca.postgresql.org/docs/aw_pgsql_book/node106.html

Hardware Performance Tuning
http://www.ca.postgresql.org/docs/momjian/hw_performance/





^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: problems with postgresql speed
@ 2001-12-03 23:23  Jeremy Buchmann <jeremy@wellsgaming.com>
  parent: Ludva Radomír (KM) <Radomir.Ludva@cssz.cz>
  1 sibling, 0 replies; 7+ messages in thread

From: Jeremy Buchmann @ 2001-12-03 23:23 UTC (permalink / raw)
  To: Ludva Radomír (KM) <Radomir.Ludva@cssz.cz>; +Cc: pgsql-admin

On Monday, December 3, 2001, at 04:30 AM, Ludva Radomír (KM) wrote:
>
> Two machines:
> 1. Pentium3 400Mhz, hdd 8Gb, 64Mb RAM, kernel 2.2.14-5.0 (RedHat 6.2)
> 2. Celeron  400Mhz, hdd 8Gb, 64Mb RAM, kernel 2.2.14-5.0 (RedHat 6.2)
>
> The same database, the same postgres Version 7.1.3, the same 
> configuration.
> Only processor is diferent, ...
>
> Queryes from client application on Windows over ODBC:
> 1. 40sec.
> 2. 90sec.

This may be due to the difference between the cache sizes of the two
processors.  IIRC, the celeron has only 128k of cache while the P3 has
512k.  Even though the P3 cache runs slower (I think the celeron runs
at full clock while the P3 runs at 1/2 clock), the larger size may 
prevent
a lot more cache misses which makes it much faster.

Databases are extremely I/O bound, so anything you can
stuff into cache is probably worth it.

--Jeremy




^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: problems with postgresql speed
@ 2001-12-04 15:47  Jay Wren <jrwren@xmtp.net>
  parent: Ludva Radomír (KM) <Radomir.Ludva@cssz.cz>
  1 sibling, 0 replies; 7+ messages in thread

From: Jay Wren @ 2001-12-04 15:47 UTC (permalink / raw)
  To: Ludva Radomír (KM) <Radomir.Ludva@cssz.cz>; +Cc: pgsql-admin


I know someone already pointed out the cache differences between the
processors, and that is likely to contribute to the differences you have
observed.

As was stated in the message about cache, databases are extremely IO
bound.  It is worth noting that Celeron's have a Front Side Bus speed of
66Mhz, while P3's have a FSB of 100Mhz or 133Mhz.  If you are running a
133MHz FSB, that is twice the data rate between your RAM and your CPU than
the Celeron.

Also, you seem to imply the systems are identical other than the CPU, but
Disk IO is nearly always the bottleneck in any system.  If one disk is
slower than the other, great differences in speed can be noticed even in
the same system.

Finally, my guess is that the P3's greater cache and faster memory bus
are what give over twice the performance on the P3.

-J

On Mon, 3 Dec 2001, [iso-8859-2] Ludva Radomír (KM) wrote:

> I have got the same problem.
> I am working on it about a month :(.
> It is not hot :-)
>
> Two machines:
> 1. Pentium3 400Mhz, hdd 8Gb, 64Mb RAM, kernel 2.2.14-5.0 (RedHat 6.2)
> 2. Celeron  400Mhz, hdd 8Gb, 64Mb RAM, kernel 2.2.14-5.0 (RedHat 6.2)
>
> The same database, the same postgres Version 7.1.3, the same configuration.
> Only processor is diferent, ...
>
> Queryes from client application on Windows over ODBC:
> 1. 40sec.
> 2. 90sec.
>
> Radmi
>
> ---
> Odchozí zpráva neobsahuje viry.
> Zkontrolováno antivirovým systémem AVG (http://www.grisoft.cz).
> Verze: 6.0.303 / Virová báze: 164 - datum vydání: 24.11.2001
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>




^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: problems with postgresql speed
@ 2001-12-04 16:31  Shaun Thomas <sthomas@townnews.com>
  parent: Manuel Trujillo <manueltrujillo@dorna.es>
  1 sibling, 0 replies; 7+ messages in thread

From: Shaun Thomas @ 2001-12-04 16:31 UTC (permalink / raw)
  To: Manuel Trujillo <manueltrujillo@dorna.es>; +Cc: pgsql-admin

On Mon, 3 Dec 2001, Manuel Trujillo wrote:

> SELECT d.gallery_id, e.subevent_id, d.result_type_id,
> d.result_type_name, e.language_id FROM ((SELECT b.gallery_id,
> b.element_id AS result_type_id, c.name AS result_type_name FROM
> gallery_element b, result_type c WHERE ((c.id = b.element_id) AND
> (b.element_type_id = 10))) d JOIN (SELECT b.gallery_id, b.element_id AS
> subevent_id, c.language_id FROM gallery_element b, view_subevent_info c
> WHERE ((c.subevent_id = b.element_id) AND (b.element_type_id = 9))) e ON
> ((d.gallery_id = e.gallery_id)));

Eww.

After expanding it, and rewriting it to be a self-join:

SELECT gm.gallery_id, gm.element_id as result_type_id,
       gs.element_id AS subevent_id, t.name, v.language_id
  FROM gallery_element gm, gallery_element gs,
       result_type t, view_subevent_info v
 WHERE gm.gallery_id = gs.gallery_id
   AND gm.element_type_id = 10
   AND gs.element_type_id = 9
   AND t.id = gm.element_id
   AND v.subevent_id = gs.element_id

This should not only work the same way, but be much faster.  Then again,
when you have to resort to something as disgusting as a self-join, I'd
want to guess the schema needs to be denormalized slightly.  A certain
amount of replication can intensely speed up and simplify queries.

Then again, I just don't like circular referencing things anyhow, but
that's just me.

-- 
+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
| Shaun M. Thomas                INN Database Programmer              |
| Phone: (309) 743-0812          Fax  : (309) 743-0830                |
| Email: sthomas@townnews.com    AIM  : trifthen                      |
| Web  : hamster.lee.net                                              |
|                                                                     |
|     "Most of our lives are about proving something, either to       |
|      ourselves or to someone else."                                 |
|                                           -- Anonymous              |
+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+





^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2001-12-04 16:31 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-12-03 10:14 problems with postgresql speed Manuel Trujillo <manueltrujillo@dorna.es>
2001-12-03 12:10 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
2001-12-04 16:31 ` Shaun Thomas <sthomas@townnews.com>
2001-12-03 12:30 Re: problems with postgresql speed Ludva Radomír (KM) <Radomir.Ludva@cssz.cz>
2001-12-03 23:23 ` Jeremy Buchmann <jeremy@wellsgaming.com>
2001-12-04 15:47 ` Jay Wren <jrwren@xmtp.net>
2001-12-03 12:53 FW: problems with postgresql speed Arguile <arguile@lucentstudios.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox