![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
|
Hi all, I am quite new to PGSql and I used to try out MySQL. What I often need is to know the number of records of every table or the max value of a |
#2
| |||
| |||
|
|
I am quite new to PGSql and I used to try out MySQL. What I often need is to know the number of records of every table or the max value of a peculiarfield (usually a date) of every one of the tables in my schema. In MySQL I found that a simple: SELECT myUnion.tab_name, myUnion.cnt AS "count" FROM ( (SELECT "t01" AS tab_name, count(*) FROM t01 WHERE boolField = 0) UNION ( ... ) UNION ( ... ) ... [about 50 tables] ... ) AS myUnion; .. was quite ok, being the first call quite fast (200 ms?) and the followingones almost instantaneous thanks to the caching of queries. |
|
In PG I found that the same query performs very poorly (same DB converted via mysql2pgsql.perl) on the same computer (A64 X2 2 GHz, 2 GB RAM) taking about 1500 ms each time (with a decent amount of HD loading activity evenrepeating the same query again and again...). My questions are: - Is there a smarter way to make a similar query that performs quite faster? - Is it possible to activate some kind of query caching or better usage of the system memory to reduce HD usage (my DB is quite small, no more than 10.000 records in the heaviest tables and many are sub 20)? |
#3
| |||
| |||
|
|
I am quite new to PGSql and I used to try out MySQL. What I often need is to know the number of records of every table or the max value of a peculiarfield (usually a date) of every one of the tables in my schema. In MySQL I found that a simple: SELECT myUnion.tab_name, myUnion.cnt AS "count" FROM ( (SELECT "t01" AS tab_name, count(*) FROM t01 WHERE boolField = 0) UNION ( ... ) UNION ( ... ) ... [about 50 tables] ... ) AS myUnion; .. was quite ok, being the first call quite fast (200 ms?) and the followingones almost instantaneous thanks to the caching of queries. Do you mean "caching of queries" or "caching of query results"? Obviously the second one, or at least that's how I think MySQL cache works. The fact is that there all my operations are seamless, just caching the tables in the RAM should give a notable performance boost to pgsql, wouldn't it? |
![]() |
| Thread Tools | |
| Display Modes | |
| |