select * from foo (100 000 rows) takes 4 seconds, is this normal?
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开发者_如何学JAVA 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 ?
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.
Connect to local database using psql:
psql -U username dbname
Turn on displaying of timing information:
dbname=> \timing
Timing is on.
Set output to local temporary file:
dbname=> \o /tmp/foo.txt
Select all rows from your table to temporary file:
dbname=> select * from foo;
Time: 104.442 ms
(On client - I assume Linux) Temporarily disable firewall:
# service iptables stop
(On client) Start listening on port 10000:
# nc -l 10000 > /dev/null
(On server) Send a file to client using plain TCP:
# time nc client_ip 10000 < /tmp/foo.txt
real 0m0.190s
user 0m0.004s
sys 0m0.078s
(On client) Enable firewall back:
# service iptables start
精彩评论