Reputation: 5246
In PostgreSQL database I have such table:
CREATE TABLE IF NOT EXISTS layers (ID NUMERIC, GEOM GEOMETRY, CITY VARCHAR, AGGREGATION_METHOD VARCHAR, INFO JSON);
I am tring to insert to that table ~700
records with such one query:
INSERT INTO layers (ID, GEOM, CITY, AGGREGATION_METHOD, INFO) VALUES
(107509018555, '0203000020E61000000100000005000000000000808531534000000020749D4540000000808531534000000080159E4540000000201731534000000080159E4540000000201731534000000020749D4540000000808531534000000020749D4540', 'New York', 'MONTHLY', '[{"time":"2019-10-01T00:00:00Z","gender_details":[{"gender":"Male"},{"gender":"Female"}]}]'),
(107509018556, '0303000020E610000001000000050000000000008085315340000000A0D29A4640000000808531534000000020749D4540000000201731534000000020749D45400000002017315340000000A0D29C45400000008085315340000000A0D29C4540', 'London', 'MONTHLY', '[{"time":"2019-10-01T00:00:00Z","gender_details":[{"gender":"Male"},{"gender":"Female"}]}]')
... other 698 values
That query runs for 9-10 seconds. Is there a way to speed up the insert request in the PostgreSQL database?
PostgreSQL version: 11.0 (running on Red Hat)
Upvotes: 0
Views: 434
Reputation: 1252
Off topic: consider using JSONB type instead of JSON.
Upvotes: 3