views:

165

answers:

2

I have postgres 8.4 installed on ubuntu server with 4 GB Ram and Intel E5504 2Ghz

I've created one table

create table foo
(
id serial primary key,
fname varchar(30),
lname varchar(30)
) 

the insert of 10 000 rows takes about 4 seconds first time and 1 second after
but the select of 100 000 rows takes 4 seconds always,

select * from foo

is this normal or my configuration could be wrong ?

could it be that my ubuntu remote bandwith is limited or something like that ?

+6  A: 

100000 rows of your table use 6.4 MBytes (or 12.4 MBytes if they are Unicode). This corresponds to 64 MBits, which takes about 6.4 seconds in a 10 MBit/s network. Therefore, the available network bandwidth may cause the 4 second delay that you are experiencing.

fmunkert
@fmunkert yes the postgre is utf-8, I'm doing the same with my sql server express on another server (same config) and it takes 1 sec, but sqlexpress is SQL_Latin1_General_CP1_CI_AS
Omu
Try to execute the same statement directly on the DB server. If it also takes 4 seconds, then the network is not the problem. If it substantially faster, then the network is the problem. In case the network is not the problem, maybe the table cache allocated on the DB server is not large enough.
fmunkert
Unicode does not mean 2 bytes per character. This is up to the specific encoding (e.g. UTF-8 uses one byte for ASCII).
musiKk
@fmunkert in the console it's instant, i don't see any delay (although i see only the first 10 rows, and I have to scroll, I'm not sure if it took all or it just selected first 10)
Omu
@fmunkert I've created another database with LATIN10, and the results are the same
Omu
I do not think that it has to do anything with ANSI or UNICODE; it probably has only to do with the amount of data that has to be transferred via the network. As a test, you could export your table to a text file and check how large the text file is. Then copy the text file from your database server to your client computer. If this takes 3-4 seconds, then you know why it is so slow. If takes less than a second, you probably have to find the reason elsewhere (e.g. on the database server: not enough RAM for caching, slow disks, etc.).
fmunkert
@fmunkert my network is 100MBit/s
Omu
+3  A: 
Tometzky
@Tometzky locally I got the time 93 ms, what can I do to make it to to also work fast remotely (windows 7 pgadmin III) ?
Omu
I think this is PgAdmin's fault, not Postgres. Try the same using psql client: "psql -h servername -U username dbname" and then "\o foo.txt", "select * from foo" from your client. PgAdmin is probably creating 100k-row widget to display your results and this is where your 4s goes.
Tometzky
thank you, in this way I got 306 ms on the client (30 locally)
Omu