patternsqlMinor
Postgres ClientWrite Event
Viewed 0 times
clientwritepostgresevent
Problem
I have a Postgres 10.9 table that has ~200 million rows. This table has an index on one of the fields my_date which is obviously a Date. I'm executing the following query:
The explain call yields the following:
An extraordinary amount of time is spend (60%) in the ClientWrite event which I see whenever I perform the following query:
30% is in the DataFileRead.
Postgres documentation describes ClientWrite as "Waiting to write data to the client." Is there a way to tell why it is waiting? I'm performing the query from PGAdmin on a machine where not much else is going on. Total time to complete is at least 5 to 10 minutes. I feel that this should be going much faster.
I checked to see when the table was last vacuumed and it says two days ago.
select my_date from my_table. The explain call yields the following:
Index Only Scan using client_purchaseorder_facility_alias_id_po_date_idx
on client_purchaseorder (cost=0.57..5981683.41 rows=196100256 width=4)An extraordinary amount of time is spend (60%) in the ClientWrite event which I see whenever I perform the following query:
select pid, wait_event_type, wait_event
from pg_stat_activity
where wait_event is NOT NULL;30% is in the DataFileRead.
Postgres documentation describes ClientWrite as "Waiting to write data to the client." Is there a way to tell why it is waiting? I'm performing the query from PGAdmin on a machine where not much else is going on. Total time to complete is at least 5 to 10 minutes. I feel that this should be going much faster.
I checked to see when the table was last vacuumed and it says two days ago.
Solution
pgAdmin is known to be slow and inefficient with large result sets, so this is not surprising. It is not built for mass data display.
If you want to visualize a sample, add a
If you want to export the data, use the
If you want to visualize a sample, add a
LIMIT clause to the query.If you want to export the data, use the
COPY statement.Context
StackExchange Database Administrators Q#258471, answer score: 2
Revisions (0)
No revisions yet.