小编doc*_*why的帖子

PostgreSQL 50M+行表聚合查询

问题陈述

\n\n

我有表“event_statistics”,其定义如下:

\n\n
CREATE TABLE public.event_statistics (\n    id int4 NOT NULL DEFAULT nextval(\'event_statistics_id_seq\'::regclass),\n    client_id int4 NULL,\n    session_id int4 NULL,\n    action_name text NULL,\n    value text NULL,\n    product_id int8 NULL,\n    product_options jsonb NOT NULL DEFAULT \'{}\'::jsonb,\n    url text NULL,\n    url_options jsonb NOT NULL DEFAULT \'{}\'::jsonb,\n    visit int4 NULL DEFAULT 0,\n    date_update timestamptz NULL,\nCONSTRAINT event_statistics_pkey PRIMARY KEY (id),\nCONSTRAINT event_statistics_client_id_session_id_sessions_client_id_id_for \nFOREIGN KEY \n(client_id,session_id) REFERENCES <?>() ON DELETE CASCADE ON UPDATE CASCADE\n)\nWITH (\n    OIDS=FALSE\n) ;\nCREATE INDEX regdate ON public.event_statistics (date_update \ntimestamptz_ops) ;\n
Run Code Online (Sandbox Code Playgroud)\n\n

和表“客户”: …

sql postgresql aggregate query-optimization

5
推荐指数
1
解决办法
2339
查看次数

标签 统计

aggregate ×1

postgresql ×1

query-optimization ×1

sql ×1