Skip to content

Instantly share code, notes, and snippets.

@EdwardIII
Created April 17, 2020 15:18
Show Gist options
  • Save EdwardIII/2d45ab140dd26994473156f4f5baea12 to your computer and use it in GitHub Desktop.
Save EdwardIII/2d45ab140dd26994473156f4f5baea12 to your computer and use it in GitHub Desktop.
Entries query
// These are all the queries being run
// also this is a bit slow
[10s] SELECT "entries".* FROM "entries" WHERE "entries"."referrer" = $1 ORDER BY "entries"."created_at" DESC [["referrer", "http://localhost"]]
[10s] SELECT COUNT(*) FROM "entries" WHERE "entries"."referrer" = $1 AND "entries"."widget_id" = $2 AND (content -> 'action' ? 'open' and content -> 'type' ? 'slide_callout') AND (created_at >= '1970-04-17 14:57:56.675928' AND created_at <= '2020-04-17 14:57:59.557860') [["referrer", "http://localhost"], ["widget_id", 1]]
[10s] SELECT COUNT(*) FROM "entries" WHERE "entries"."referrer" = $1 [["referrer", "http://localhost"]]
// this one seems to be the culprit
[10s] SELECT "entries".* FROM "entries" WHERE "entries"."referrer" = $1 AND (extract(year from created_at) = '2020') AND (extract(month from created_at) = '04') ORDER BY "entries"."created_at" DESC [["referrer", "http://localhost"]]
@oluyoung
Copy link

Entry Load (1328.6ms)  SELECT "entries".* FROM "entries" WHERE "entries"."referrer" = $1 AND (extract(year from created_at) = '2020') AND (extract(month from created_at) = '04') ORDER BY "entries"."created_at" DESC  [["referrer", "http://localhost"]]

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