Skip to content

Instantly share code, notes, and snippets.

@ioquatix
Created April 19, 2017 03:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ioquatix/bddda36d9e4ffaceb7a62d7b62259121 to your computer and use it in GitHub Desktop.
Save ioquatix/bddda36d9e4ffaceb7a62d7b62259121 to your computer and use it in GitHub Desktop.
user_event schema
Table "public.user_event"
Column | Type | Modifiers
-------------+-----------------------------+---------------------------------------------------------
id | integer | not null default nextval('user_event_id_seq'::regclass)
user_id | integer | not null
latitude | numeric(9,6) |
longitude | numeric(9,6) |
active | boolean | not null default true
poi_id | integer |
deal_id | integer |
category_id | integer |
what | character varying(32) | not null
locale | character varying(8) |
created_at | timestamp without time zone | not null
parameters | jsonb |
Indexes:
"user_event_pkey" PRIMARY KEY, btree (id)
"index_user_event_for_calls" btree (poi_id, created_at) WHERE what::text = 'profile_call'::text
"index_user_event_for_nearby_polls" btree (created_at, latitude, longitude) WHERE what::text = ANY (ARRAY['location_change'::character varying, 'poll'::character varying, 'midnight_location'::character varying]::text[])
"index_user_event_for_profile_views" btree (poi_id, created_at) WHERE what::text = 'poi_profile_shown'::text
"index_user_event_for_profile_views1" btree (poi_id, created_at, what) WHERE what::text = 'poi_profile_shown'::text
"index_user_event_for_profile_views2" btree (created_at, poi_id, what) WHERE what::text = 'poi_profile_shown'::text
"index_user_event_for_suggestion_notification" btree (((parameters ->> 'suggestion_id'::text)::integer), what) WHERE (parameters ->> 'suggestion_id'::text) IS NOT NULL
"index_user_event_for_visits" btree (poi_id, created_at, latitude, longitude) WHERE what::text = 'location_change'::text
"index_user_event_for_visits_3" btree (created_at, latitude, longitude, user_id) WHERE what::text = ANY (ARRAY['location_change'::character varying, 'poll'::character varying, 'midnight_location'::character varying]::text[])
"index_user_event_for_web_clicks" btree (poi_id, created_at) WHERE what::text = 'profile_weblink'::text
"index_user_event_on_created_at" btree (created_at)
"index_user_event_on_user_id_and_created_at_and_what" btree (user_id, created_at, what) WHERE what::text = ANY (ARRAY['location_change'::character varying, 'menu_tap'::character varying, 'poi_profile_shown'::character varying]::text[])
@ioquatix
Copy link
Author

After doing the alter table, it wouldn't do the index only scan. Found out you need to vacuum analyze user_event from http://ask.use-the-index-luke.com/questions/148/why-is-this-postgres-query-doing-a-bitmap-heap-scan-after-the-index-scan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment