PgHero

Queries

Total Time Average Time Calls
143,132 min 24% 4 ms 2,040,772,270 ankipro
SELECT "v2"."decks"."id" FROM "v2"."decks" WHERE ("v2"."decks"."ancestry" LIKE $1 OR "v2"."decks"."id" = $2) AND "v2"."decks"."state" != $3
31,256 min 5% 13 ms 149,693,349 ankipro
WITH subtree_decks AS ( SELECT id, ancestry FROM v2.decks WHERE (id IN ($1) OR ancestry LIKE $2) AND state NOT IN ($3,$4,$5) ), min_next_reviews AS ( SELECT deck_id, MIN(next_review_at) AS min_next_review_at FROM v2.card_progresses WHERE deck_id IN (SELECT id FROM subtree_decks) AND user_id = $6 AND frozen = $7 GROUP BY deck_id ) SELECT sd.id AS deck_id, sd.ancestry, mn.min_next_review_at FROM subtree_decks sd LEFT JOIN min_next_reviews mn ON sd.id = mn.deck_id
23,987 min 4% 415 ms 3,469,146 ankipro
SELECT "v2"."decks"."id", "v2"."decks"."deck_collaborators_count", "v2"."decks"."deleted_by_user_at", "v2"."decks"."downvotes", "v2"."decks"."import_error_message", "v2"."decks"."name", "v2"."decks"."last_reset_at", "v2"."decks"."public_state", "v2"."decks"."sharing_token", "v2"."decks"."state", "v2"."decks"."visibility", "v2"."decks"."upvotes", "v2"."decks"."user_id", "v2"."decks"."created_at", "v2"."decks"."updated_at", "v2"."decks"."ancestry", "v2"."decks"."slug", "v2"."decks"."seo_description", "v2"."decks"."description", "v2"."decks"."category", "v2"."decks"."cloned_times_count", "v2"."decks"."is_indexable", "v2"."decks"."study_score", "v2"."decks"."library_deck_id", "v2"."decks"."file_hash", "v2"."decks"."cloned_from_id", "v2"."decks"."anki_deck_id", "v2"."decks"."studiers_count", "v2"."decks"."deck_id", "v2"."decks"."moved_at", "v2"."decks"."source", "v2"."decks"."reviews_count", "v2"."decks"."duplicated_from_id", "v2"."decks"."no_cards_limit", "v2"."decks"."category_id" FROM "v2"."decks" WHERE "v2"."decks"."public_state" = $1 AND "v2"."decks"."ancestry" = $2 AND "v2"."decks"."sharing_token" = $3 LIMIT $4
19,426 min 3% 3 ms 418,933,056 ankipro
SELECT "v2"."card_progresses"."id", "v2"."card_progresses"."ease_factor", "v2"."card_progresses"."frozen", "v2"."card_progresses"."interval", "v2"."card_progresses"."learning_state", "v2"."card_progresses"."learning_steps_index", "v2"."card_progresses"."next_review_at", "v2"."card_progresses"."ordinal", "v2"."card_progresses"."raw_next_review_at", "v2"."card_progresses"."to_learn_in_current_sl_round", "v2"."card_progresses"."note_id", "v2"."card_progresses"."user_id", "v2"."card_progresses"."created_at", "v2"."card_progresses"."updated_at", "v2"."card_progresses"."fetch_priority", "v2"."card_progresses"."deck_id", "v2"."card_progresses"."undo_data" FROM "v2"."card_progresses" WHERE "v2"."card_progresses"."note_id" = $1 AND "v2"."card_progresses"."ordinal" = $2 AND "v2"."card_progresses"."user_id" = $3 LIMIT $4
Covered by index on (note_id)
Rows: 112469624
Row progression: 112469624, 0

Row estimates
- note_id (=): 0
- user_id (=): 770
- ordinal (=): 112469624

Existing indexes
- id PRIMARY
- id, deck_id PRIMARY
- deck_id
- deck_id, id
- deck_id, user_id, note_id
- library_card_id
- library_note_id
- note_id
- user_id
- user_id, frozen
- user_id, id
- user_id, note_id
14,525 min 2% 3 ms 261,778,693 ankipro
SELECT "v2"."card_progresses"."note_id" FROM "v2"."card_progresses" WHERE "v2"."card_progresses"."deck_id" = $1 AND "v2"."card_progresses"."user_id" = $2 AND "v2"."card_progresses"."frozen" = $3
Covered by index on (deck_id, user_id, note_id)
Rows: 112469624
Row progression: 112469624, 273, 0

Row estimates
- deck_id (=): 273
- user_id (=): 770
- frozen (=): 56234812

Existing indexes
- id PRIMARY
- id, deck_id PRIMARY
- deck_id
- deck_id, id
- deck_id, user_id, note_id
- library_card_id
- library_note_id
- note_id
- user_id
- user_id, frozen
- user_id, id
- user_id, note_id
14,477 min 2% 8 ms 111,463,752 ankipro
SELECT "v2"."note_attachments"."id", "v2"."note_attachments"."note_id", "v2"."note_attachments"."deck_id", "v2"."note_attachments"."attachment_id", "v2"."note_attachments"."kind", "v2"."note_attachments"."created_at", "v2"."note_attachments"."updated_at", "v2"."note_attachments"."field_name" FROM "v2"."note_attachments" WHERE "v2"."note_attachments"."note_id" IN ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20)
13,555 min 2% 5 ms 158,218,732 ankipro
SELECT "v2"."notes"."id", "v2"."notes"."template_kind", "v2"."notes"."fields", "v2"."notes"."cards_count", "v2"."notes"."deck_id", "v2"."notes"."created_at", "v2"."notes"."updated_at", "v2"."notes"."library_note_id", "v2"."notes"."library_card_id", "v2"."notes"."anki_id", "v2"."notes"."css" FROM "v2"."notes" WHERE "v2"."notes"."id" = $1 LIMIT $2
13,515 min 2% 1 ms 728,976,935 ankipro
SELECT COUNT(id) AS total, SUM(CASE WHEN NOT frozen AND learning_state = $1 THEN $2 ELSE $3 END) AS new, SUM(CASE WHEN NOT frozen AND learning_state = $4 AND next_review_at < $5 THEN $6 ELSE $7 END) AS learning, SUM(CASE WHEN NOT frozen AND learning_state = $8 AND next_review_at < $9 THEN $10 ELSE $11 END) AS graduated, SUM(CASE WHEN NOT frozen AND learning_state = $12 THEN $13 ELSE $14 END) AS learning_total, SUM(CASE WHEN NOT frozen AND learning_state = $15 THEN $16 ELSE $17 END) AS graduated_total, SUM(CASE WHEN NOT frozen AND learning_state = $18 THEN $19 ELSE $20 END) AS study_again, SUM(CASE WHEN NOT frozen AND learning_state = $21 THEN $22 ELSE $23 END) AS got_it, SUM(CASE WHEN frozen THEN $24 ELSE $25 END) as frozen, SUM(CASE WHEN NOT frozen AND learning_state IN($26, $27, $28) AND next_review_at < $29 THEN $30 ELSE $31 END) as offline_available, MIN(CASE WHEN NOT frozen AND next_review_at > $32 THEN next_review_at ELSE $33 END) as recalculate_at FROM v2.card_progresses WHERE user_id = $34 AND deck_id IN ($35)
Covered by index on (deck_id, user_id, note_id)
Rows: 112469624
Row progression: 112469624, 273, 0

Row estimates
- deck_id (=): 273
- user_id (=): 770

Existing indexes
- id PRIMARY
- id, deck_id PRIMARY
- deck_id
- deck_id, id
- deck_id, user_id, note_id
- library_card_id
- library_note_id
- note_id
- user_id
- user_id, frozen
- user_id, id
- user_id, note_id
12,174 min 2% 0 ms 2,073,168,544 ankipro
SELECT "v2"."deck_counters"."id", "v2"."deck_counters"."recalculate_at", "v2"."deck_counters"."deck_id" FROM "v2"."deck_counters" WHERE "v2"."deck_counters"."deck_id" IN ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) AND "v2"."deck_counters"."user_id" = $11
Covered by index on (deck_id)
Rows: 40145496
Row progression: 40145496, 1

Row estimates
- deck_id (=): 1
- user_id (=): 447

Existing indexes
- id PRIMARY
- id, deck_id PRIMARY
- deck_id
- deck_id, user_id UNIQUE
- user_id
- user_id
11,797 min 2% 7 ms 95,943,565 ankipro
SELECT "v2"."note_attachments"."id", "v2"."note_attachments"."note_id", "v2"."note_attachments"."deck_id", "v2"."note_attachments"."attachment_id", "v2"."note_attachments"."kind", "v2"."note_attachments"."created_at", "v2"."note_attachments"."updated_at", "v2"."note_attachments"."field_name" FROM "v2"."note_attachments" WHERE "v2"."note_attachments"."note_id" IN ($1, $2, $3, $4, $5, $6, $7)
9,470 min 2% 5 ms 116,366,333 ankipro
SELECT "v2"."note_attachments"."id", "v2"."note_attachments"."note_id", "v2"."note_attachments"."deck_id", "v2"."note_attachments"."attachment_id", "v2"."note_attachments"."kind", "v2"."note_attachments"."created_at", "v2"."note_attachments"."updated_at", "v2"."note_attachments"."field_name" FROM "v2"."note_attachments" WHERE "v2"."note_attachments"."note_id" = $1
9,363 min 2% 7 ms 77,689,015 ankipro
SELECT notes.id, notes.deck_id, notes.template_kind, notes.fields, notes.cards_count, notes.css, notes.created_at FROM v2.notes AS notes WHERE notes.deck_id IN ($1) ORDER BY notes.created_at DESC, notes.id DESC OFFSET $2 LIMIT $3
8,968 min 1% 4 ms 120,788,081 ankipro
SELECT "v2"."decks"."id" FROM "v2"."decks" WHERE "v2"."decks"."state" != $1 AND "v2"."decks"."id" IN (SELECT "v2"."deck_settings"."deck_id" FROM "v2"."deck_settings" WHERE "v2"."deck_settings"."user_id" = $2 AND "v2"."deck_settings"."state" = $3)
8,301 min 1% 4 ms 119,068,211 ankipro
SELECT "v2"."decks"."id" FROM "v2"."decks" WHERE ("v2"."decks"."ancestry" LIKE $1 OR "v2"."decks"."id" = $2)
8,017 min 1% 2 ms 268,181,276 ankipro
SELECT "v2"."deck_settings"."deck_id" FROM "v2"."deck_settings" WHERE "v2"."deck_settings"."user_id" = $1 AND "v2"."deck_settings"."state" = $2
7,529 min 1% 4 ms 106,187,652 ankipro
SELECT "v2"."note_attachments"."attachment_id" FROM "v2"."note_attachments" WHERE "v2"."note_attachments"."note_id" = $1
7,480 min 1% 22 ms 20,456,957 ankipro
WITH cte AS ( SELECT id, deck_id, (sum(v2.notes.cards_count) over (order by v2.notes.id)) AS custom_offset FROM v2.notes WHERE $1=$2 AND v2.notes.id IN ($3) ORDER BY id ASC LIMIT $4 ) SELECT * FROM v2.notes AS notes INNER JOIN cte AS c ON c.id = notes.id AND c.deck_id = notes.deck_id AND c.custom_offset > $5 WHERE $6=$7 ORDER BY notes.id ASC LIMIT $8
7,098 min 1% 1 ms 650,668,139 ankipro
SELECT DISTINCT "v2"."decks"."id" FROM "v2"."decks" INNER JOIN "v2"."deck_settings" ON "v2"."deck_settings"."deck_id" = "v2"."decks"."id" INNER JOIN "v2"."deck_counters" ON "v2"."deck_counters"."deck_id" = "v2"."decks"."id" WHERE ("v2"."decks"."state" IN ($1, $2, $3, $4, $5, $6) AND "v2"."decks"."public_state" = $7 OR "v2"."decks"."state" = $8 OR "v2"."decks"."state" = $9) AND (v2.deck_settings.user_id = $10 AND v2.deck_counters.user_id = $11) AND "v2"."decks"."id" = $12 LIMIT $13
7,033 min 1% 0 ms 1,088,660,582 ankipro
SELECT "v2"."decks"."id", "v2"."decks"."deck_collaborators_count", "v2"."decks"."deleted_by_user_at", "v2"."decks"."downvotes", "v2"."decks"."import_error_message", "v2"."decks"."name", "v2"."decks"."last_reset_at", "v2"."decks"."public_state", "v2"."decks"."sharing_token", "v2"."decks"."state", "v2"."decks"."visibility", "v2"."decks"."upvotes", "v2"."decks"."user_id", "v2"."decks"."created_at", "v2"."decks"."updated_at", "v2"."decks"."ancestry", "v2"."decks"."slug", "v2"."decks"."seo_description", "v2"."decks"."description", "v2"."decks"."category", "v2"."decks"."cloned_times_count", "v2"."decks"."is_indexable", "v2"."decks"."study_score", "v2"."decks"."library_deck_id", "v2"."decks"."file_hash", "v2"."decks"."cloned_from_id", "v2"."decks"."anki_deck_id", "v2"."decks"."studiers_count", "v2"."decks"."deck_id", "v2"."decks"."moved_at", "v2"."decks"."source", "v2"."decks"."reviews_count", "v2"."decks"."duplicated_from_id", "v2"."decks"."no_cards_limit", "v2"."decks"."category_id" FROM "v2"."decks" WHERE "v2"."decks"."id" = $1 LIMIT $2
Covered by index on (id)
Rows: 40047676
Row progression: 40047676, 1

Row estimates
- id (=): 1

Existing indexes
- id PRIMARY
- id, user_id PRIMARY
- ancestry
- ancestry text_pattern_ops
- ancestry varchar_pattern_ops
- anki_deck_id
- category_id
- cloned_from_id
- deck_import_id
- deleted_by_user_at, user_id
- id, state
- library_deck_id
- public_state, visibility
- sharing_token varchar_pattern_ops UNIQUE
- state
- user_id
- user_id
6,184 min 1% 2 ms 164,528,916 ankipro
SELECT "v2"."deck_settings"."deck_id" FROM "v2"."deck_settings" WHERE "v2"."deck_settings"."user_id" = $1 AND "v2"."deck_settings"."folder_id" IS NULL
4,855 min 0.8% 9 ms 33,306,445 ankipro
SELECT "v2"."note_attachments"."id", "v2"."note_attachments"."note_id", "v2"."note_attachments"."deck_id", "v2"."note_attachments"."attachment_id", "v2"."note_attachments"."kind", "v2"."note_attachments"."created_at", "v2"."note_attachments"."updated_at", "v2"."note_attachments"."field_name" FROM "v2"."note_attachments" WHERE "v2"."note_attachments"."note_id" IN ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35, $36, $37, $38, $39, $40, $41, $42, $43, $44, $45, $46, $47, $48, $49, $50)
4,653 min 0.8% 30 ms 9,337,313 ankipro
WITH subtree_decks AS ( SELECT id, ancestry FROM v2.decks WHERE (id IN ($1,$2,$3,$4) OR ancestry LIKE $5 OR ancestry LIKE $6 OR ancestry LIKE $7 OR ancestry LIKE $8) AND state NOT IN ($9,$10,$11) ), min_next_reviews AS ( SELECT deck_id, MIN(next_review_at) AS min_next_review_at FROM v2.card_progresses WHERE deck_id IN (SELECT id FROM subtree_decks) AND user_id = $12 AND frozen = $13 GROUP BY deck_id ) SELECT sd.id AS deck_id, sd.ancestry, mn.min_next_review_at FROM subtree_decks sd LEFT JOIN min_next_reviews mn ON sd.id = mn.deck_id
4,627 min 0.8% 19 ms 14,308,233 ankipro
WITH subtree_decks AS ( SELECT id, ancestry FROM v2.decks WHERE (id IN ($1,$2) OR ancestry LIKE $3 OR ancestry LIKE $4) AND state NOT IN ($5,$6,$7) ), min_next_reviews AS ( SELECT deck_id, MIN(next_review_at) AS min_next_review_at FROM v2.card_progresses WHERE deck_id IN (SELECT id FROM subtree_decks) AND user_id = $8 AND frozen = $9 GROUP BY deck_id ) SELECT sd.id AS deck_id, sd.ancestry, mn.min_next_review_at FROM subtree_decks sd LEFT JOIN min_next_reviews mn ON sd.id = mn.deck_id
4,559 min 0.8% 25 ms 10,788,773 ankipro
WITH subtree_decks AS ( SELECT id, ancestry FROM v2.decks WHERE (id IN ($1,$2,$3) OR ancestry LIKE $4 OR ancestry LIKE $5 OR ancestry LIKE $6) AND state NOT IN ($7,$8,$9) ), min_next_reviews AS ( SELECT deck_id, MIN(next_review_at) AS min_next_review_at FROM v2.card_progresses WHERE deck_id IN (SELECT id FROM subtree_decks) AND user_id = $10 AND frozen = $11 GROUP BY deck_id ) SELECT sd.id AS deck_id, sd.ancestry, mn.min_next_review_at FROM subtree_decks sd LEFT JOIN min_next_reviews mn ON sd.id = mn.deck_id
4,426 min 0.7% 33 ms 7,929,334 ankipro
WITH subtree_decks AS ( SELECT id, ancestry FROM v2.decks WHERE (id IN ($1,$2,$3,$4,$5) OR ancestry LIKE $6 OR ancestry LIKE $7 OR ancestry LIKE $8 OR ancestry LIKE $9 OR ancestry LIKE $10) AND state NOT IN ($11,$12,$13) ), min_next_reviews AS ( SELECT deck_id, MIN(next_review_at) AS min_next_review_at FROM v2.card_progresses WHERE deck_id IN (SELECT id FROM subtree_decks) AND user_id = $14 AND frozen = $15 GROUP BY deck_id ) SELECT sd.id AS deck_id, sd.ancestry, mn.min_next_review_at FROM subtree_decks sd LEFT JOIN min_next_reviews mn ON sd.id = mn.deck_id
4,385 min 0.7% 5 ms 56,367,616 ankipro
SELECT $1 AS one FROM "v2"."decks" WHERE ("v2"."decks"."ancestry" LIKE $2 OR "v2"."decks"."id" = $3) AND "v2"."decks"."state" != $4 AND "v2"."decks"."state" IN ($5, $6, $7, $8, $9, $10) LIMIT $11
4,068 min 0.7% 0 ms 1,559,421,104 ankipro
UPDATE "users" SET "last_seen_time" = $1, "last_seen_ip" = $2, "country_code" = $3 WHERE "users"."id" = $4
Covered by index on (id, timezone_offset)
Rows: 8717733
Row progression: 8717733, 1

Row estimates
- id (=): 1

Existing indexes
- id PRIMARY
- analytics_id
- country_code
- email varchar_pattern_ops
- id, timezone_offset
- locale, email WHERE (email IS NOT NULL) AND (onboarding_data IS NOT NULL) AND ((email)::text !~~ '%private%'::text)
- lower((email)::text)
- qon_id
- reset_password_token WHERE reset_password_token IS NOT NULL
- stripe_customer_id
- uid, provider UNIQUE
- username UNIQUE
4,032 min 0.7% 37 ms 6,512,966 ankipro
WITH subtree_decks AS ( SELECT id, ancestry FROM v2.decks WHERE (id IN ($1,$2,$3,$4,$5,$6) OR ancestry LIKE $7 OR ancestry LIKE $8 OR ancestry LIKE $9 OR ancestry LIKE $10 OR ancestry LIKE $11 OR ancestry LIKE $12) AND state NOT IN ($13,$14,$15) ), min_next_reviews AS ( SELECT deck_id, MIN(next_review_at) AS min_next_review_at FROM v2.card_progresses WHERE deck_id IN (SELECT id FROM subtree_decks) AND user_id = $16 AND frozen = $17 GROUP BY deck_id ) SELECT sd.id AS deck_id, sd.ancestry, mn.min_next_review_at FROM subtree_decks sd LEFT JOIN min_next_reviews mn ON sd.id = mn.deck_id
3,636 min 0.6% 40 ms 5,439,806 ankipro
WITH subtree_decks AS ( SELECT id, ancestry FROM v2.decks WHERE (id IN ($1,$2,$3,$4,$5,$6,$7) OR ancestry LIKE $8 OR ancestry LIKE $9 OR ancestry LIKE $10 OR ancestry LIKE $11 OR ancestry LIKE $12 OR ancestry LIKE $13 OR ancestry LIKE $14) AND state NOT IN ($15,$16,$17) ), min_next_reviews AS ( SELECT deck_id, MIN(next_review_at) AS min_next_review_at FROM v2.card_progresses WHERE deck_id IN (SELECT id FROM subtree_decks) AND user_id = $18 AND frozen = $19 GROUP BY deck_id ) SELECT sd.id AS deck_id, sd.ancestry, mn.min_next_review_at FROM subtree_decks sd LEFT JOIN min_next_reviews mn ON sd.id = mn.deck_id
3,200 min 0.5% 42 ms 4,552,616 ankipro
WITH subtree_decks AS ( SELECT id, ancestry FROM v2.decks WHERE (id IN ($1,$2,$3,$4,$5,$6,$7,$8) OR ancestry LIKE $9 OR ancestry LIKE $10 OR ancestry LIKE $11 OR ancestry LIKE $12 OR ancestry LIKE $13 OR ancestry LIKE $14 OR ancestry LIKE $15 OR ancestry LIKE $16) AND state NOT IN ($17,$18,$19) ), min_next_reviews AS ( SELECT deck_id, MIN(next_review_at) AS min_next_review_at FROM v2.card_progresses WHERE deck_id IN (SELECT id FROM subtree_decks) AND user_id = $20 AND frozen = $21 GROUP BY deck_id ) SELECT sd.id AS deck_id, sd.ancestry, mn.min_next_review_at FROM subtree_decks sd LEFT JOIN min_next_reviews mn ON sd.id = mn.deck_id
3,191 min 0.5% 18 ms 10,603,653 ankipro
SELECT "v2"."decks"."id", "v2"."decks"."deck_collaborators_count", "v2"."decks"."deleted_by_user_at", "v2"."decks"."downvotes", "v2"."decks"."import_error_message", "v2"."decks"."name", "v2"."decks"."last_reset_at", "v2"."decks"."public_state", "v2"."decks"."sharing_token", "v2"."decks"."state", "v2"."decks"."visibility", "v2"."decks"."upvotes", "v2"."decks"."user_id", "v2"."decks"."created_at", "v2"."decks"."updated_at", "v2"."decks"."ancestry", "v2"."decks"."slug", "v2"."decks"."seo_description", "v2"."decks"."description", "v2"."decks"."category", "v2"."decks"."cloned_times_count", "v2"."decks"."is_indexable", "v2"."decks"."study_score", "v2"."decks"."library_deck_id", "v2"."decks"."file_hash", "v2"."decks"."cloned_from_id", "v2"."decks"."anki_deck_id", "v2"."decks"."studiers_count", "v2"."decks"."deck_id", "v2"."decks"."moved_at", "v2"."decks"."source", "v2"."decks"."reviews_count", "v2"."decks"."duplicated_from_id", "v2"."decks"."no_cards_limit", "v2"."decks"."category_id" FROM "v2"."decks" WHERE "v2"."decks"."public_state" = $1 AND "v2"."decks"."ancestry" = $2 AND "v2"."decks"."visibility" IN ($3, $4) AND "v2"."decks"."slug" IS NOT NULL AND "v2"."decks"."library_deck_id" = $5 LIMIT $6
2,862 min 0.5% 45 ms 3,821,348 ankipro
WITH subtree_decks AS ( SELECT id, ancestry FROM v2.decks WHERE (id IN ($1,$2,$3,$4,$5,$6,$7,$8,$9) OR ancestry LIKE $10 OR ancestry LIKE $11 OR ancestry LIKE $12 OR ancestry LIKE $13 OR ancestry LIKE $14 OR ancestry LIKE $15 OR ancestry LIKE $16 OR ancestry LIKE $17 OR ancestry LIKE $18) AND state NOT IN ($19,$20,$21) ), min_next_reviews AS ( SELECT deck_id, MIN(next_review_at) AS min_next_review_at FROM v2.card_progresses WHERE deck_id IN (SELECT id FROM subtree_decks) AND user_id = $22 AND frozen = $23 GROUP BY deck_id ) SELECT sd.id AS deck_id, sd.ancestry, mn.min_next_review_at FROM subtree_decks sd LEFT JOIN min_next_reviews mn ON sd.id = mn.deck_id
2,756 min 0.5% 0 ms 438,916,300 ankipro
SELECT "v2"."deck_settings"."id", "v2"."deck_settings"."algorithm_preset", "v2"."deck_settings"."deck_id", "v2"."deck_settings"."easy_interval_minutes", "v2"."deck_settings"."easy_bonus_percent", "v2"."deck_settings"."font_settings", "v2"."deck_settings"."graduated_interval_minutes", "v2"."deck_settings"."interval_modifier_percent", "v2"."deck_settings"."last_sync_at", "v2"."deck_settings"."library_sharing", "v2"."deck_settings"."new_cards_per_day", "v2"."deck_settings"."reverse_mode", "v2"."deck_settings"."offline_mode", "v2"."deck_settings"."sharing", "v2"."deck_settings"."steps_in_minutes", "v2"."deck_settings"."shuffle_mode", "v2"."deck_settings"."tts_autoplay", "v2"."deck_settings"."tts", "v2"."deck_settings"."tts_back_side_language", "v2"."deck_settings"."tts_front_side_language", "v2"."deck_settings"."user_id", "v2"."deck_settings"."created_at", "v2"."deck_settings"."updated_at", "v2"."deck_settings"."position", "v2"."deck_settings"."tts_whole_card_pronunciation", "v2"."deck_settings"."state", "v2"."deck_settings"."max_cards_per_day", "v2"."deck_settings"."card_preset_id", "v2"."deck_settings"."max_interval_minutes", "v2"."deck_settings"."tts_speed", "v2"."deck_settings"."tts_slower_replay", "v2"."deck_settings"."folder_id" FROM "v2"."deck_settings" WHERE "v2"."deck_settings"."deck_id" = $1
Covered by index on (deck_id)
Rows: 40252212
Row progression: 40252212, 1

Row estimates
- deck_id (=): 1

Existing indexes
- id PRIMARY
- id, deck_id PRIMARY
- deck_id
- deck_id
- folder_id
- user_id
- user_id
2,608 min 0.4% 46 ms 3,369,329 ankipro
WITH subtree_decks AS ( SELECT id, ancestry FROM v2.decks WHERE (id IN ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10) OR ancestry LIKE $11 OR ancestry LIKE $12 OR ancestry LIKE $13 OR ancestry LIKE $14 OR ancestry LIKE $15 OR ancestry LIKE $16 OR ancestry LIKE $17 OR ancestry LIKE $18 OR ancestry LIKE $19 OR ancestry LIKE $20) AND state NOT IN ($21,$22,$23) ), min_next_reviews AS ( SELECT deck_id, MIN(next_review_at) AS min_next_review_at FROM v2.card_progresses WHERE deck_id IN (SELECT id FROM subtree_decks) AND user_id = $24 AND frozen = $25 GROUP BY deck_id ) SELECT sd.id AS deck_id, sd.ancestry, mn.min_next_review_at FROM subtree_decks sd LEFT JOIN min_next_reviews mn ON sd.id = mn.deck_id
2,463 min 0.4% 24 ms 6,197,809 ankipro
WITH cte AS ( SELECT id, deck_id, (sum(v2.notes.cards_count) over (order by v2.notes.id)) AS custom_offset FROM v2.notes WHERE $1=$2 AND v2.notes.id IN ($3,$4,$5,$6,$7) ORDER BY id ASC LIMIT $8 ) SELECT * FROM v2.notes AS notes INNER JOIN cte AS c ON c.id = notes.id AND c.deck_id = notes.deck_id AND c.custom_offset > $9 WHERE $10=$11 ORDER BY notes.id ASC LIMIT $12
2,373 min 0.4% 49 ms 2,917,594 ankipro
WITH subtree_decks AS ( SELECT id, ancestry FROM v2.decks WHERE (id IN ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11) OR ancestry LIKE $12 OR ancestry LIKE $13 OR ancestry LIKE $14 OR ancestry LIKE $15 OR ancestry LIKE $16 OR ancestry LIKE $17 OR ancestry LIKE $18 OR ancestry LIKE $19 OR ancestry LIKE $20 OR ancestry LIKE $21 OR ancestry LIKE $22) AND state NOT IN ($23,$24,$25) ), min_next_reviews AS ( SELECT deck_id, MIN(next_review_at) AS min_next_review_at FROM v2.card_progresses WHERE deck_id IN (SELECT id FROM subtree_decks) AND user_id = $26 AND frozen = $27 GROUP BY deck_id ) SELECT sd.id AS deck_id, sd.ancestry, mn.min_next_review_at FROM subtree_decks sd LEFT JOIN min_next_reviews mn ON sd.id = mn.deck_id
2,284 min 0.4% 0 ms 378,577,816 ankipro
SELECT "v2"."decks"."id", "v2"."decks"."deck_collaborators_count", "v2"."decks"."deleted_by_user_at", "v2"."decks"."downvotes", "v2"."decks"."import_error_message", "v2"."decks"."name", "v2"."decks"."last_reset_at", "v2"."decks"."public_state", "v2"."decks"."sharing_token", "v2"."decks"."state", "v2"."decks"."visibility", "v2"."decks"."upvotes", "v2"."decks"."user_id", "v2"."decks"."created_at", "v2"."decks"."updated_at", "v2"."decks"."ancestry", "v2"."decks"."slug", "v2"."decks"."seo_description", "v2"."decks"."description", "v2"."decks"."category", "v2"."decks"."cloned_times_count", "v2"."decks"."is_indexable", "v2"."decks"."study_score", "v2"."decks"."library_deck_id", "v2"."decks"."file_hash", "v2"."decks"."cloned_from_id", "v2"."decks"."anki_deck_id", "v2"."decks"."studiers_count", "v2"."decks"."deck_id", "v2"."decks"."moved_at", "v2"."decks"."source", "v2"."decks"."reviews_count", "v2"."decks"."duplicated_from_id", "v2"."decks"."no_cards_limit", "v2"."decks"."category_id" FROM "v2"."decks" WHERE "v2"."decks"."id" = $1
Covered by index on (id)
Rows: 40047676
Row progression: 40047676, 1

Row estimates
- id (=): 1

Existing indexes
- id PRIMARY
- id, user_id PRIMARY
- ancestry
- ancestry text_pattern_ops
- ancestry varchar_pattern_ops
- anki_deck_id
- category_id
- cloned_from_id
- deck_import_id
- deleted_by_user_at, user_id
- id, state
- library_deck_id
- public_state, visibility
- sharing_token varchar_pattern_ops UNIQUE
- state
- user_id
- user_id
2,251 min 0.4% 23 ms 5,881,741 ankipro
WITH cte AS ( SELECT id, deck_id, (sum(v2.notes.cards_count) over (order by v2.notes.id)) AS custom_offset FROM v2.notes WHERE $1=$2 AND v2.notes.id IN ($3,$4,$5) ORDER BY id ASC LIMIT $6 ) SELECT * FROM v2.notes AS notes INNER JOIN cte AS c ON c.id = notes.id AND c.deck_id = notes.deck_id AND c.custom_offset > $7 WHERE $8=$9 ORDER BY notes.id ASC LIMIT $10
2,236 min 0.4% 1 ms 262,244,417 ankipro
UPDATE "v2"."deck_counters" SET "recalculate_at" = $1, "updated_at" = $2 WHERE "v2"."deck_counters"."id" = $3 AND "v2"."deck_counters"."deck_id" = $4
Covered by index on (id)
Rows: 40145496
Row progression: 40145496, 1

Row estimates
- id (=): 1
- deck_id (=): 1

Existing indexes
- id PRIMARY
- id, deck_id PRIMARY
- deck_id
- deck_id, user_id UNIQUE
- user_id
- user_id
2,084 min 0.3% 50 ms 2,496,012 ankipro
WITH subtree_decks AS ( SELECT id, ancestry FROM v2.decks WHERE (id IN ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12) OR ancestry LIKE $13 OR ancestry LIKE $14 OR ancestry LIKE $15 OR ancestry LIKE $16 OR ancestry LIKE $17 OR ancestry LIKE $18 OR ancestry LIKE $19 OR ancestry LIKE $20 OR ancestry LIKE $21 OR ancestry LIKE $22 OR ancestry LIKE $23 OR ancestry LIKE $24) AND state NOT IN ($25,$26,$27) ), min_next_reviews AS ( SELECT deck_id, MIN(next_review_at) AS min_next_review_at FROM v2.card_progresses WHERE deck_id IN (SELECT id FROM subtree_decks) AND user_id = $28 AND frozen = $29 GROUP BY deck_id ) SELECT sd.id AS deck_id, sd.ancestry, mn.min_next_review_at FROM subtree_decks sd LEFT JOIN min_next_reviews mn ON sd.id = mn.deck_id
2,048 min 0.3% 0 ms 1,603,850,537 ankipro
SELECT "streaks"."id", "streaks"."duration", "streaks"."end_date", "streaks"."days_until_next_freeze" FROM "streaks" WHERE "streaks"."user_id" = $1
Covered by index on (user_id)
Rows: 5408244
Row progression: 5408244, 15

Row estimates
- user_id (=): 15

Existing indexes
- id PRIMARY
- user_id
- user_id, daterange(start_date, end_date, '[)'::text) GIST
- user_id WHERE end_date IS NULL UNIQUE
2,008 min 0.3% 8 ms 14,289,757 ankipro
UPDATE "v2"."decks" SET "state" = $1 WHERE "v2"."decks"."ancestry" LIKE $2 AND "v2"."decks"."state" != $3
Details
CREATE INDEX CONCURRENTLY ON decks USING gist (ancestry gist_trgm_ops)
Rows: 40047676
Row progression: 40047676, 3392148

Row estimates
- ancestry (~~): 3392148
- state (<>): 32038141

Existing indexes
- id PRIMARY
- id, user_id PRIMARY
- ancestry
- ancestry text_pattern_ops
- ancestry varchar_pattern_ops
- anki_deck_id
- category_id
- cloned_from_id
- deck_import_id
- deleted_by_user_at, user_id
- id, state
- library_deck_id
- public_state, visibility
- sharing_token varchar_pattern_ops UNIQUE
- state
- user_id
- user_id
1,948 min 0.3% 5 ms 21,392,602 ankipro
SELECT "v2"."note_attachments"."id", "v2"."note_attachments"."note_id", "v2"."note_attachments"."deck_id", "v2"."note_attachments"."attachment_id", "v2"."note_attachments"."kind", "v2"."note_attachments"."created_at", "v2"."note_attachments"."updated_at", "v2"."note_attachments"."field_name" FROM "v2"."note_attachments" WHERE "v2"."note_attachments"."note_id" IN ($1, $2, $3)
1,921 min 0.3% 2 ms 70,127,903 ankipro
SELECT notes.id, notes.deck_id, notes.template_kind, notes.fields, notes.cards_count, notes.css, notes.created_at FROM v2.notes AS notes WHERE notes.deck_id IN ($1) ORDER BY notes.created_at DESC, notes.id DESC LIMIT $2
1,918 min 0.3% 5 ms 21,459,498 ankipro
SELECT "v2"."note_attachments"."id", "v2"."note_attachments"."note_id", "v2"."note_attachments"."deck_id", "v2"."note_attachments"."attachment_id", "v2"."note_attachments"."kind", "v2"."note_attachments"."created_at", "v2"."note_attachments"."updated_at", "v2"."note_attachments"."field_name" FROM "v2"."note_attachments" WHERE "v2"."note_attachments"."note_id" IN ($1, $2)
1,880 min 0.3% 8 ms 13,678,819 ankipro
SELECT "v2"."notes"."id", "v2"."notes"."template_kind", "v2"."notes"."fields", "v2"."notes"."cards_count", "v2"."notes"."deck_id", "v2"."notes"."created_at", "v2"."notes"."updated_at", "v2"."notes"."library_note_id", "v2"."notes"."library_card_id", "v2"."notes"."anki_id", "v2"."notes"."css" FROM "v2"."notes" WHERE "v2"."notes"."id" IN ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35, $36, $37, $38, $39, $40, $41, $42, $43, $44, $45, $46, $47, $48, $49, $50)
1,839 min 0.3% 52 ms 2,125,600 ankipro
WITH subtree_decks AS ( SELECT id, ancestry FROM v2.decks WHERE (id IN ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13) OR ancestry LIKE $14 OR ancestry LIKE $15 OR ancestry LIKE $16 OR ancestry LIKE $17 OR ancestry LIKE $18 OR ancestry LIKE $19 OR ancestry LIKE $20 OR ancestry LIKE $21 OR ancestry LIKE $22 OR ancestry LIKE $23 OR ancestry LIKE $24 OR ancestry LIKE $25 OR ancestry LIKE $26) AND state NOT IN ($27,$28,$29) ), min_next_reviews AS ( SELECT deck_id, MIN(next_review_at) AS min_next_review_at FROM v2.card_progresses WHERE deck_id IN (SELECT id FROM subtree_decks) AND user_id = $30 AND frozen = $31 GROUP BY deck_id ) SELECT sd.id AS deck_id, sd.ancestry, mn.min_next_review_at FROM subtree_decks sd LEFT JOIN min_next_reviews mn ON sd.id = mn.deck_id
1,766 min 0.3% 0 ms 231,236,696 ankipro
UPDATE "v2"."deck_counters" SET "reviewed_today_count" = $1, "recalculate_at" = $2, "to_learn_today_count" = $3, "updated_at" = $4 WHERE "v2"."deck_counters"."id" = $5 AND "v2"."deck_counters"."deck_id" = $6
Covered by index on (id)
Rows: 40145496
Row progression: 40145496, 1

Row estimates
- id (=): 1
- deck_id (=): 1

Existing indexes
- id PRIMARY
- id, deck_id PRIMARY
- deck_id
- deck_id, user_id UNIQUE
- user_id
- user_id
1,730 min 0.3% 8 ms 12,546,664 ankipro
SELECT "v2"."notes"."id", "v2"."notes"."template_kind", "v2"."notes"."fields", "v2"."notes"."cards_count", "v2"."notes"."deck_id", "v2"."notes"."css" FROM "v2"."notes" WHERE "v2"."notes"."deck_id" = $1 AND "v2"."notes"."id" > $2 ORDER BY "v2"."notes"."id" ASC LIMIT $3
1,671 min 0.3% 54 ms 1,860,015 ankipro
WITH subtree_decks AS ( SELECT id, ancestry FROM v2.decks WHERE (id IN ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14) OR ancestry LIKE $15 OR ancestry LIKE $16 OR ancestry LIKE $17 OR ancestry LIKE $18 OR ancestry LIKE $19 OR ancestry LIKE $20 OR ancestry LIKE $21 OR ancestry LIKE $22 OR ancestry LIKE $23 OR ancestry LIKE $24 OR ancestry LIKE $25 OR ancestry LIKE $26 OR ancestry LIKE $27 OR ancestry LIKE $28) AND state NOT IN ($29,$30,$31) ), min_next_reviews AS ( SELECT deck_id, MIN(next_review_at) AS min_next_review_at FROM v2.card_progresses WHERE deck_id IN (SELECT id FROM subtree_decks) AND user_id = $32 AND frozen = $33 GROUP BY deck_id ) SELECT sd.id AS deck_id, sd.ancestry, mn.min_next_review_at FROM subtree_decks sd LEFT JOIN min_next_reviews mn ON sd.id = mn.deck_id
1,664 min 0.3% 1 ms 94,282,833 ankipro
SELECT "v2"."card_progresses"."note_id", "v2"."card_progresses"."next_review_at", "v2"."card_progresses"."learning_state", "v2"."card_progresses"."frozen", "v2"."card_progresses"."ordinal" FROM "v2"."card_progresses" WHERE "v2"."card_progresses"."deck_id" = $1 AND "v2"."card_progresses"."note_id" IN ($2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21) AND "v2"."card_progresses"."user_id" = $22
Covered by index on (note_id)
Rows: 112469624
Row progression: 112469624, 0

Row estimates
- note_id (=): 0
- deck_id (=): 273
- user_id (=): 770

Existing indexes
- id PRIMARY
- id, deck_id PRIMARY
- deck_id
- deck_id, id
- deck_id, user_id, note_id
- library_card_id
- library_note_id
- note_id
- user_id
- user_id, frozen
- user_id, id
- user_id, note_id
1,643 min 0.3% 0 ms 11,691,953,342 ankipro
SET application_name='/home/application/bundle/ruby/3.4.0/bin/rake'
1,605 min 0.3% 2 ms 51,464,558 ankipro
SELECT * FROM v2.notes WHERE deck_id IN ($1) AND TRIM( REGEXP_REPLACE( REGEXP_REPLACE( LOWER(notes.fields->>$2), $3, $4, $5 ), $6, $7, $8 ) ) = LOWER(TRIM($9)) ORDER BY id ASC
1,596 min 0.3% 23 ms 4,255,981 ankipro
WITH cte AS ( SELECT id, deck_id, (sum(v2.notes.cards_count) over (order by v2.notes.id)) AS custom_offset FROM v2.notes WHERE $1=$2 AND v2.notes.id IN ($3,$4) ORDER BY id ASC LIMIT $5 ) SELECT * FROM v2.notes AS notes INNER JOIN cte AS c ON c.id = notes.id AND c.deck_id = notes.deck_id AND c.custom_offset > $6 WHERE $7=$8 ORDER BY notes.id ASC LIMIT $9
1,596 min 0.3% 57 ms 1,692,528 ankipro
WITH subtree_decks AS ( SELECT id, ancestry FROM v2.decks WHERE (id IN ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15) OR ancestry LIKE $16 OR ancestry LIKE $17 OR ancestry LIKE $18 OR ancestry LIKE $19 OR ancestry LIKE $20 OR ancestry LIKE $21 OR ancestry LIKE $22 OR ancestry LIKE $23 OR ancestry LIKE $24 OR ancestry LIKE $25 OR ancestry LIKE $26 OR ancestry LIKE $27 OR ancestry LIKE $28 OR ancestry LIKE $29 OR ancestry LIKE $30) AND state NOT IN ($31,$32,$33) ), min_next_reviews AS ( SELECT deck_id, MIN(next_review_at) AS min_next_review_at FROM v2.card_progresses WHERE deck_id IN (SELECT id FROM subtree_decks) AND user_id = $34 AND frozen = $35 GROUP BY deck_id ) SELECT sd.id AS deck_id, sd.ancestry, mn.min_next_review_at FROM subtree_decks sd LEFT JOIN min_next_reviews mn ON sd.id = mn.deck_id
1,511 min 0.2% 0 ms 11,716,835,108 ankipro
SET application_name='/home/application/bundle/ruby/3.4.0/bin/pitchfork'
1,497 min 0.2% 0 ms 13,697,705,554 ankipro
SELECT $1 AS one FROM "solid_queue_ready_executions" WHERE "solid_queue_ready_executions"."queue_name" = $2 LIMIT $3 FOR UPDATE SKIP LOCKED
1,462 min 0.2% 0 ms 1,849,293,696 ankipro
SELECT "users"."id", "users"."analytics_id", "users"."uid", "users"."apple_auth", "users"."timezone_offset", "users"."created_at", "users"."updated_at", "users"."onboarding_data", "users"."experiments", "users"."locale", "users"."provider", "users"."email", "users"."password_digest", "users"."current_app_version", "users"."premium", "users"."reset_password_token", "users"."reset_password_sent_at", "users"."app_features", "users"."metadata", "users"."name", "users"."username", "users"."avatar_color", "users"."country_code", "users"."qr_token", "users"."qr_token_expires_at", "users"."last_seen_time", "users"."last_seen_ip", "users"."qon_id", "users"."stripe_customer_id", "users"."avatar", "users"."first_destroy_reminder_sent", "users"."second_destroy_reminder_sent", "users"."generated", "users"."new_architecture", "users"."state", "users"."idfa", "users"."aaid", "users"."about", "users"."funnel_fox_id", "users"."referral_code" FROM "users" WHERE "users"."id" = $1 LIMIT $2
Covered by index on (id, timezone_offset)
Rows: 8717733
Row progression: 8717733, 1

Row estimates
- id (=): 1

Existing indexes
- id PRIMARY
- analytics_id
- country_code
- email varchar_pattern_ops
- id, timezone_offset
- locale, email WHERE (email IS NOT NULL) AND (onboarding_data IS NOT NULL) AND ((email)::text !~~ '%private%'::text)
- lower((email)::text)
- qon_id
- reset_password_token WHERE reset_password_token IS NOT NULL
- stripe_customer_id
- uid, provider UNIQUE
- username UNIQUE
1,427 min 0.2% 6 ms 14,885,028 ankipro
SELECT "v2"."note_attachments"."id", "v2"."note_attachments"."note_id", "v2"."note_attachments"."deck_id", "v2"."note_attachments"."attachment_id", "v2"."note_attachments"."kind", "v2"."note_attachments"."created_at", "v2"."note_attachments"."updated_at", "v2"."note_attachments"."field_name" FROM "v2"."note_attachments" WHERE "v2"."note_attachments"."note_id" IN ($1, $2, $3, $4, $5)
1,417 min 0.2% 1 ms 159,651,491 ankipro
UPDATE "v2"."deck_counters" SET "recalculate_at" = $1 WHERE "v2"."deck_counters"."id" = $2 AND "v2"."deck_counters"."deck_id" = $3
Covered by index on (id)
Rows: 40145496
Row progression: 40145496, 1

Row estimates
- id (=): 1
- deck_id (=): 1

Existing indexes
- id PRIMARY
- id, deck_id PRIMARY
- deck_id
- deck_id, user_id UNIQUE
- user_id
- user_id
1,346 min 0.2% 0 ms 210,679,363 ankipro
SELECT "v2"."deck_settings"."id", "v2"."deck_settings"."algorithm_preset", "v2"."deck_settings"."deck_id", "v2"."deck_settings"."easy_interval_minutes", "v2"."deck_settings"."easy_bonus_percent", "v2"."deck_settings"."font_settings", "v2"."deck_settings"."graduated_interval_minutes", "v2"."deck_settings"."interval_modifier_percent", "v2"."deck_settings"."last_sync_at", "v2"."deck_settings"."library_sharing", "v2"."deck_settings"."new_cards_per_day", "v2"."deck_settings"."reverse_mode", "v2"."deck_settings"."offline_mode", "v2"."deck_settings"."sharing", "v2"."deck_settings"."steps_in_minutes", "v2"."deck_settings"."shuffle_mode", "v2"."deck_settings"."tts_autoplay", "v2"."deck_settings"."tts", "v2"."deck_settings"."tts_back_side_language", "v2"."deck_settings"."tts_front_side_language", "v2"."deck_settings"."user_id", "v2"."deck_settings"."created_at", "v2"."deck_settings"."updated_at", "v2"."deck_settings"."position", "v2"."deck_settings"."tts_whole_card_pronunciation", "v2"."deck_settings"."state", "v2"."deck_settings"."max_cards_per_day", "v2"."deck_settings"."card_preset_id", "v2"."deck_settings"."max_interval_minutes", "v2"."deck_settings"."tts_speed", "v2"."deck_settings"."tts_slower_replay", "v2"."deck_settings"."folder_id" FROM "v2"."deck_settings" WHERE "v2"."deck_settings"."deck_id" = $1 AND "v2"."deck_settings"."user_id" = $2
Covered by index on (deck_id)
Rows: 40252212
Row progression: 40252212, 1

Row estimates
- deck_id (=): 1
- user_id (=): 170

Existing indexes
- id PRIMARY
- id, deck_id PRIMARY
- deck_id
- deck_id
- folder_id
- user_id
- user_id
1,322 min 0.2% 6 ms 13,770,896 ankipro
INSERT INTO "v2"."notes" ("id","template_kind","fields","cards_count","deck_id","created_at","updated_at","library_note_id","library_card_id","anki_id","css") VALUES (nextval($1),$2,$3,$4,$5,$6,$7,$8,$9,$10,$11),(nextval($12),$13,$14,$15,$16,$17,$18,$19,$20,$21,$22),(nextval($23),$24,$25,$26,$27,$28,$29,$30,$31,$32,$33),(nextval($34),$35,$36,$37,$38,$39,$40,$41,$42,$43,$44),(nextval($45),$46,$47,$48,$49,$50,$51,$52,$53,$54,$55),(nextval($56),$57,$58,$59,$60,$61,$62,$63,$64,$65,$66),(nextval($67),$68,$69,$70,$71,$72,$73,$74,$75,$76,$77),(nextval($78),$79,$80,$81,$82,$83,$84,$85,$86,$87,$88),(nextval($89),$90,$91,$92,$93,$94,$95,$96,$97,$98,$99),(nextval($100),$101,$102,$103,$104,$105,$106,$107,$108,$109,$110),(nextval($111),$112,$113,$114,$115,$116,$117,$118,$119,$120,$121),(nextval($122),$123,$124,$125,$126,$127,$128,$129,$130,$131,$132),(nextval($133),$134,$135,$136,$137,$138,$139,$140,$141,$142,$143),(nextval($144),$145,$146,$147,$148,$149,$150,$151,$152,$153,$154),(nextval($155),$156,$157,$158,$159,$160,$161,$162,$163,$164,$165),(nextval($166),$167,$168,$169,$170,$171,$172,$173,$174,$175,$176),(nextval($177),$178,$179,$180,$181,$182,$183,$184,$185,$186,$187),(nextval($188),$189,$190,$191,$192,$193,$194,$195,$196,$197,$198),(nextval($199),$200,$201,$202,$203,$204,$205,$206,$207,$208,$209),(nextval($210),$211,$212,$213,$214,$215,$216,$217,$218,$219,$220),(nextval($221),$222,$223,$224,$225,$226,$227,$228,$229,$230,$231),(nextval($232),$233,$234,$235,$236,$237,$238,$239,$240,$241,$242),(nextval($243),$244,$245,$246,$247,$248,$249,$250,$251,$252,$253),(nextval($254),$255,$256,$257,$258,$259,$260,$261,$262,$263,$264),(nextval($265),$266,$267,$268,$269,$270,$271,$272,$273,$274,$275),(nextval($276),$277,$278,$279,$280,$281,$282,$283,$284,$285,$286),(nextval($287),$288,$289,$290,$291,$292,$293,$294,$295,$296,$297),(nextval($298),$299,$300,$301,$302,$303,$304,$305,$306,$307,$308),(nextval($309),$310,$311,$312,$313,$314,$315,$316,$317,$318,$319),(nextval($320),$321,$322,$323,$324,$325,$326,$327,$328,$329,$330),(nextval($331),$332,$333,$334,$335,$336,$337,$338,$339,$340,$341),(nextval($342),$343,$344,$345,$346,$347,$348,$349,$350,$351,$352),(nextval($353),$354,$355,$356,$357,$358,$359,$360,$361,$362,$363),(nextval($364),$365,$366,$367,$368,$369,$370,$371,$372,$373,$374),(nextval($375),$376,$377,$378,$379,$380,$381,$382,$383,$384,$385),(nextval($386),$387,$388,$389,$390,$391,$392,$393,$394,$395,$396),(nextval($397),$398,$399,$400,$401,$402,$403,$404,$405,$406,$407),(nextval($408),$409,$410,$411,$412,$413,$414,$415,$416,$417,$418),(nextval($419),$420,$421,$422,$423,$424,$425,$426,$427,$428,$429),(nextval($430),$431,$432,$433,$434,$435,$436,$437,$438,$439,$440),(nextval($441),$442,$443,$444,$445,$446,$447,$448,$449,$450,$451),(nextval($452),$453,$454,$455,$456,$457,$458,$459,$460,$461,$462),(nextval($463),$464,$465,$466,$467,$468,$469,$470,$471,$472,$473),(nextval($474),$475,$476,$477,$478,$479,$480,$481,$482,$483,$484),(nextval($485),$486,$487,$488,$489,$490,$491,$492,$493,$494,$495),(nextval($496),$497,$498,$499,$500,$501,$502,$503,$504,$505,$506),(nextval($507),$508,$509,$510,$511,$512,$513,$514,$515,$516,$517),(nextval($518),$519,$520,$521,$522,$523,$524,$525,$526,$527,$528),(nextval($529),$530,$531,$532,$533,$534,$535,$536,$537,$538,$539),(nextval($540),$541,$542,$543,$544,$545,$546,$547,$548,$549,$550) RETURNING "id"
1,304 min 0.2% 1 ms 80,177,430 ankipro
SELECT "v2"."card_progresses"."id", "v2"."card_progresses"."ease_factor", "v2"."card_progresses"."frozen", "v2"."card_progresses"."interval", "v2"."card_progresses"."learning_state", "v2"."card_progresses"."learning_steps_index", "v2"."card_progresses"."next_review_at", "v2"."card_progresses"."ordinal", "v2"."card_progresses"."raw_next_review_at", "v2"."card_progresses"."to_learn_in_current_sl_round", "v2"."card_progresses"."note_id", "v2"."card_progresses"."user_id", "v2"."card_progresses"."created_at", "v2"."card_progresses"."updated_at", "v2"."card_progresses"."fetch_priority", "v2"."card_progresses"."deck_id", "v2"."card_progresses"."undo_data" FROM "v2"."card_progresses" WHERE "v2"."card_progresses"."id" IN ($1, $2, $3, $4, $5, $6, $7) AND "v2"."card_progresses"."deck_id" = $8 AND "v2"."card_progresses"."frozen" = $9
Covered by index on (id)
Rows: 112469624
Row progression: 112469624, 1

Row estimates
- id (=): 1
- deck_id (=): 273
- frozen (=): 56234812

Existing indexes
- id PRIMARY
- id, deck_id PRIMARY
- deck_id
- deck_id, id
- deck_id, user_id, note_id
- library_card_id
- library_note_id
- note_id
- user_id
- user_id, frozen
- user_id, id
- user_id, note_id
1,292 min 0.2% 57 ms 1,367,561 ankipro
WITH subtree_decks AS ( SELECT id, ancestry FROM v2.decks WHERE (id IN ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16) OR ancestry LIKE $17 OR ancestry LIKE $18 OR ancestry LIKE $19 OR ancestry LIKE $20 OR ancestry LIKE $21 OR ancestry LIKE $22 OR ancestry LIKE $23 OR ancestry LIKE $24 OR ancestry LIKE $25 OR ancestry LIKE $26 OR ancestry LIKE $27 OR ancestry LIKE $28 OR ancestry LIKE $29 OR ancestry LIKE $30 OR ancestry LIKE $31 OR ancestry LIKE $32) AND state NOT IN ($33,$34,$35) ), min_next_reviews AS ( SELECT deck_id, MIN(next_review_at) AS min_next_review_at FROM v2.card_progresses WHERE deck_id IN (SELECT id FROM subtree_decks) AND user_id = $36 AND frozen = $37 GROUP BY deck_id ) SELECT sd.id AS deck_id, sd.ancestry, mn.min_next_review_at FROM subtree_decks sd LEFT JOIN min_next_reviews mn ON sd.id = mn.deck_id
1,258 min 0.2% 61 ms 1,237,229 ankipro
WITH subtree_decks AS ( SELECT id, ancestry FROM v2.decks WHERE (id IN ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17) OR ancestry LIKE $18 OR ancestry LIKE $19 OR ancestry LIKE $20 OR ancestry LIKE $21 OR ancestry LIKE $22 OR ancestry LIKE $23 OR ancestry LIKE $24 OR ancestry LIKE $25 OR ancestry LIKE $26 OR ancestry LIKE $27 OR ancestry LIKE $28 OR ancestry LIKE $29 OR ancestry LIKE $30 OR ancestry LIKE $31 OR ancestry LIKE $32 OR ancestry LIKE $33 OR ancestry LIKE $34) AND state NOT IN ($35,$36,$37) ), min_next_reviews AS ( SELECT deck_id, MIN(next_review_at) AS min_next_review_at FROM v2.card_progresses WHERE deck_id IN (SELECT id FROM subtree_decks) AND user_id = $38 AND frozen = $39 GROUP BY deck_id ) SELECT sd.id AS deck_id, sd.ancestry, mn.min_next_review_at FROM subtree_decks sd LEFT JOIN min_next_reviews mn ON sd.id = mn.deck_id
1,244 min 0.2% 0 ms 251,010,601 ankipro
SELECT "v2"."deck_counters"."id", "v2"."deck_counters"."recalculate_at", "v2"."deck_counters"."deck_id" FROM "v2"."deck_counters" WHERE "v2"."deck_counters"."deck_id" = $1 AND "v2"."deck_counters"."user_id" = $2
Covered by index on (deck_id)
Rows: 40145496
Row progression: 40145496, 1

Row estimates
- deck_id (=): 1
- user_id (=): 447

Existing indexes
- id PRIMARY
- id, deck_id PRIMARY
- deck_id
- deck_id, user_id UNIQUE
- user_id
- user_id
1,234 min 0.2% 0 ms 212,020,677 ankipro
SELECT "v2"."notes"."id", "v2"."notes"."deck_id" FROM "v2"."notes" WHERE "v2"."notes"."deck_id" = $1 AND "v2"."notes"."id" = $2 LIMIT $3
1,149 min 0.2% 61 ms 1,129,862 ankipro
WITH subtree_decks AS ( SELECT id, ancestry FROM v2.decks WHERE (id IN ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18) OR ancestry LIKE $19 OR ancestry LIKE $20 OR ancestry LIKE $21 OR ancestry LIKE $22 OR ancestry LIKE $23 OR ancestry LIKE $24 OR ancestry LIKE $25 OR ancestry LIKE $26 OR ancestry LIKE $27 OR ancestry LIKE $28 OR ancestry LIKE $29 OR ancestry LIKE $30 OR ancestry LIKE $31 OR ancestry LIKE $32 OR ancestry LIKE $33 OR ancestry LIKE $34 OR ancestry LIKE $35 OR ancestry LIKE $36) AND state NOT IN ($37,$38,$39) ), min_next_reviews AS ( SELECT deck_id, MIN(next_review_at) AS min_next_review_at FROM v2.card_progresses WHERE deck_id IN (SELECT id FROM subtree_decks) AND user_id = $40 AND frozen = $41 GROUP BY deck_id ) SELECT sd.id AS deck_id, sd.ancestry, mn.min_next_review_at FROM subtree_decks sd LEFT JOIN min_next_reviews mn ON sd.id = mn.deck_id
1,139 min 0.2% 6 ms 11,001,863 ankipro
SELECT "v2"."note_attachments"."id", "v2"."note_attachments"."note_id", "v2"."note_attachments"."deck_id", "v2"."note_attachments"."attachment_id", "v2"."note_attachments"."kind", "v2"."note_attachments"."created_at", "v2"."note_attachments"."updated_at", "v2"."note_attachments"."field_name" FROM "v2"."note_attachments" WHERE "v2"."note_attachments"."note_id" IN ($1, $2, $3, $4, $5, $6)
1,127 min 0.2% 1 ms 79,486,211 ankipro
SELECT "v2"."notes"."id", "v2"."notes"."template_kind", "v2"."notes"."fields", "v2"."notes"."cards_count", "v2"."notes"."deck_id", "v2"."notes"."created_at", "v2"."notes"."updated_at", "v2"."notes"."library_note_id", "v2"."notes"."library_card_id", "v2"."notes"."anki_id", "v2"."notes"."css" FROM "v2"."notes" WHERE "v2"."notes"."id" IN ($1, $2, $3, $4, $5, $6, $7) AND "v2"."notes"."deck_id" = $8
1,114 min 0.2% 1 ms 49,760,962 ankipro
SELECT "v2"."card_progresses"."id" FROM "v2"."card_progresses" WHERE "v2"."card_progresses"."deck_id" = $1 AND "v2"."card_progresses"."user_id" = $2 AND "v2"."card_progresses"."frozen" = $3 AND (v2.card_progresses.next_review_at <= $4 OR v2.card_progresses.next_review_at IS NULL) AND (v2.card_progresses.to_learn_in_current_sl_round = $5 OR v2.card_progresses.to_learn_in_current_sl_round IS NULL) AND (v2.card_progresses.id IN ($6,$7,$8)) ORDER BY CASE v2.card_progresses.learning_state WHEN $9 THEN $10 WHEN $11 THEN $12 ELSE $13 END ASC, CASE WHEN v2.card_progresses.fetch_priority = $14 THEN $15 ELSE $16 END, RANDOM() LIMIT $17
1,107 min 0.2% 6 ms 11,724,539 ankipro
SELECT "v2"."note_attachments"."id", "v2"."note_attachments"."note_id", "v2"."note_attachments"."deck_id", "v2"."note_attachments"."attachment_id", "v2"."note_attachments"."kind", "v2"."note_attachments"."created_at", "v2"."note_attachments"."updated_at", "v2"."note_attachments"."field_name" FROM "v2"."note_attachments" WHERE "v2"."note_attachments"."note_id" IN ($1, $2, $3, $4)
1,082 min 0.2% 1 ms 49,843,215 ankipro
SELECT "v2"."card_progresses"."id" FROM "v2"."card_progresses" WHERE "v2"."card_progresses"."deck_id" = $1 AND "v2"."card_progresses"."user_id" = $2 AND "v2"."card_progresses"."frozen" = $3 AND (v2.card_progresses.next_review_at <= $4 OR v2.card_progresses.next_review_at IS NULL) AND (v2.card_progresses.to_learn_in_current_sl_round = $5 OR v2.card_progresses.to_learn_in_current_sl_round IS NULL) AND (learning_state IN ($6,$7,$8)) AND (v2.card_progresses.id NOT IN ($9,$10,$11)) ORDER BY CASE v2.card_progresses.learning_state WHEN $12 THEN $13 WHEN $14 THEN $15 ELSE $16 END ASC, CASE WHEN v2.card_progresses.fetch_priority = $17 THEN $18 ELSE $19 END, RANDOM() LIMIT $20
1,069 min 0.2% 66 ms 974,836 ankipro
WITH subtree_decks AS ( SELECT id, ancestry FROM v2.decks WHERE (id IN ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20) OR ancestry LIKE $21 OR ancestry LIKE $22 OR ancestry LIKE $23 OR ancestry LIKE $24 OR ancestry LIKE $25 OR ancestry LIKE $26 OR ancestry LIKE $27 OR ancestry LIKE $28 OR ancestry LIKE $29 OR ancestry LIKE $30 OR ancestry LIKE $31 OR ancestry LIKE $32 OR ancestry LIKE $33 OR ancestry LIKE $34 OR ancestry LIKE $35 OR ancestry LIKE $36 OR ancestry LIKE $37 OR ancestry LIKE $38 OR ancestry LIKE $39 OR ancestry LIKE $40) AND state NOT IN ($41,$42,$43) ), min_next_reviews AS ( SELECT deck_id, MIN(next_review_at) AS min_next_review_at FROM v2.card_progresses WHERE deck_id IN (SELECT id FROM subtree_decks) AND user_id = $44 AND frozen = $45 GROUP BY deck_id ) SELECT sd.id AS deck_id, sd.ancestry, mn.min_next_review_at FROM subtree_decks sd LEFT JOIN min_next_reviews mn ON sd.id = mn.deck_id
1,055 min 0.2% 23 ms 2,717,763 ankipro
WITH cte AS ( SELECT id, deck_id, (sum(v2.notes.cards_count) over (order by v2.notes.id)) AS custom_offset FROM v2.notes WHERE $1=$2 AND v2.notes.id IN ($3,$4,$5,$6) ORDER BY id ASC LIMIT $7 ) SELECT * FROM v2.notes AS notes INNER JOIN cte AS c ON c.id = notes.id AND c.deck_id = notes.deck_id AND c.custom_offset > $8 WHERE $9=$10 ORDER BY notes.id ASC LIMIT $11
1,045 min 0.2% 0 ms 148,032,628 ankipro
SELECT "v2"."decks"."id", "v2"."decks"."deck_collaborators_count", "v2"."decks"."deleted_by_user_at", "v2"."decks"."downvotes", "v2"."decks"."import_error_message", "v2"."decks"."name", "v2"."decks"."last_reset_at", "v2"."decks"."public_state", "v2"."decks"."sharing_token", "v2"."decks"."state", "v2"."decks"."visibility", "v2"."decks"."upvotes", "v2"."decks"."user_id", "v2"."decks"."created_at", "v2"."decks"."updated_at", "v2"."decks"."ancestry", "v2"."decks"."slug", "v2"."decks"."seo_description", "v2"."decks"."description", "v2"."decks"."category", "v2"."decks"."cloned_times_count", "v2"."decks"."is_indexable", "v2"."decks"."study_score", "v2"."decks"."library_deck_id", "v2"."decks"."file_hash", "v2"."decks"."cloned_from_id", "v2"."decks"."anki_deck_id", "v2"."decks"."studiers_count", "v2"."decks"."deck_id", "v2"."decks"."moved_at", "v2"."decks"."source", "v2"."decks"."reviews_count", "v2"."decks"."duplicated_from_id", "v2"."decks"."no_cards_limit", "v2"."decks"."category_id" FROM "v2"."decks" WHERE "v2"."decks"."public_state" = $1 AND "v2"."decks"."id" = $2 LIMIT $3
1,035 min 0.2% 2 ms 35,299,915 ankipro
SELECT "v2"."attachments"."id", "v2"."attachments"."media_kind", "v2"."attachments"."height", "v2"."attachments"."width", "v2"."attachments"."media_file", "v2"."attachments"."deck_id", "v2"."attachments"."created_at", "v2"."attachments"."updated_at", "v2"."attachments"."answer_mask", "v2"."attachments"."question_mask", "v2"."attachments"."source", "v2"."attachments"."custom_file_url" FROM "v2"."attachments" WHERE "v2"."attachments"."id" = $1
1,029 min 0.2% 18 ms 3,384,421 ankipro
SELECT "v2"."notes"."id", "v2"."notes"."template_kind", "v2"."notes"."fields", "v2"."notes"."cards_count", "v2"."notes"."deck_id", "v2"."notes"."css" FROM "v2"."notes" WHERE "v2"."notes"."deck_id" = $1 ORDER BY "v2"."notes"."id" ASC LIMIT $2
987 min 0.2% 66 ms 898,436 ankipro
SELECT DISTINCT "users"."id" AS alias_0, "users"."id" FROM "users" LEFT OUTER JOIN "subscriptions" ON "subscriptions"."user_id" = "users"."id" WHERE "subscriptions"."expires_at" < $1 AND "users"."id" > $2 ORDER BY "users"."id" ASC LIMIT $3
982 min 0.2% 0 ms 149,706,691 ankipro
SELECT "v2"."decks"."id", "v2"."decks"."deck_collaborators_count", "v2"."decks"."deleted_by_user_at", "v2"."decks"."downvotes", "v2"."decks"."import_error_message", "v2"."decks"."name", "v2"."decks"."last_reset_at", "v2"."decks"."public_state", "v2"."decks"."sharing_token", "v2"."decks"."state", "v2"."decks"."visibility", "v2"."decks"."upvotes", "v2"."decks"."user_id", "v2"."decks"."created_at", "v2"."decks"."updated_at", "v2"."decks"."ancestry", "v2"."decks"."slug", "v2"."decks"."seo_description", "v2"."decks"."description", "v2"."decks"."category", "v2"."decks"."cloned_times_count", "v2"."decks"."is_indexable", "v2"."decks"."study_score", "v2"."decks"."library_deck_id", "v2"."decks"."file_hash", "v2"."decks"."cloned_from_id", "v2"."decks"."anki_deck_id", "v2"."decks"."studiers_count", "v2"."decks"."deck_id", "v2"."decks"."moved_at", "v2"."decks"."source", "v2"."decks"."reviews_count", "v2"."decks"."duplicated_from_id", "v2"."decks"."no_cards_limit", "v2"."decks"."category_id" FROM "v2"."decks" WHERE "v2"."decks"."id" = $1 AND "v2"."decks"."ancestry" = $2
Covered by index on (id)
Rows: 40047676
Row progression: 40047676, 1

Row estimates
- id (=): 1
- ancestry (=): 32

Existing indexes
- id PRIMARY
- id, user_id PRIMARY
- ancestry
- ancestry text_pattern_ops
- ancestry varchar_pattern_ops
- anki_deck_id
- category_id
- cloned_from_id
- deck_import_id
- deleted_by_user_at, user_id
- id, state
- library_deck_id
- public_state, visibility
- sharing_token varchar_pattern_ops UNIQUE
- state
- user_id
- user_id
958 min 0.2% 61 ms 934,983 ankipro
WITH subtree_decks AS ( SELECT id, ancestry FROM v2.decks WHERE (id IN ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19) OR ancestry LIKE $20 OR ancestry LIKE $21 OR ancestry LIKE $22 OR ancestry LIKE $23 OR ancestry LIKE $24 OR ancestry LIKE $25 OR ancestry LIKE $26 OR ancestry LIKE $27 OR ancestry LIKE $28 OR ancestry LIKE $29 OR ancestry LIKE $30 OR ancestry LIKE $31 OR ancestry LIKE $32 OR ancestry LIKE $33 OR ancestry LIKE $34 OR ancestry LIKE $35 OR ancestry LIKE $36 OR ancestry LIKE $37 OR ancestry LIKE $38) AND state NOT IN ($39,$40,$41) ), min_next_reviews AS ( SELECT deck_id, MIN(next_review_at) AS min_next_review_at FROM v2.card_progresses WHERE deck_id IN (SELECT id FROM subtree_decks) AND user_id = $42 AND frozen = $43 GROUP BY deck_id ) SELECT sd.id AS deck_id, sd.ancestry, mn.min_next_review_at FROM subtree_decks sd LEFT JOIN min_next_reviews mn ON sd.id = mn.deck_id
923 min 0.2% 5 ms 11,929,162 ankipro
SELECT $1 AS one FROM "v2"."decks" WHERE ("v2"."decks"."ancestry" LIKE $2 OR "v2"."decks"."id" = $3) AND "v2"."decks"."state" != $4 AND "v2"."decks"."state" IN ($5, $6, $7, $8) LIMIT $9
906 min 0.1% 1 ms 60,367,228 ankipro
SELECT COUNT(*) FROM "v2"."notes" WHERE "v2"."notes"."deck_id" = $1
891 min 0.1% 55 ms 964,645 ankipro
WITH cte AS ( SELECT id, deck_id, (sum(v2.notes.cards_count) over (order by v2.notes.id)) AS custom_offset FROM v2.notes WHERE $1=$2 AND v2.notes.deck_id IN ($3) ORDER BY id ASC LIMIT $4 ) SELECT * FROM v2.notes AS notes INNER JOIN cte AS c ON c.id = notes.id AND c.deck_id = notes.deck_id AND c.custom_offset > $5 WHERE $6=$7 ORDER BY notes.id ASC LIMIT $8
889 min 0.1% 3 ms 19,783,783 ankipro
SELECT "v2"."card_progresses"."id", "v2"."card_progresses"."ease_factor", "v2"."card_progresses"."frozen", "v2"."card_progresses"."interval", "v2"."card_progresses"."learning_state", "v2"."card_progresses"."learning_steps_index", "v2"."card_progresses"."next_review_at", "v2"."card_progresses"."ordinal", "v2"."card_progresses"."raw_next_review_at", "v2"."card_progresses"."to_learn_in_current_sl_round", "v2"."card_progresses"."note_id", "v2"."card_progresses"."user_id", "v2"."card_progresses"."created_at", "v2"."card_progresses"."updated_at", "v2"."card_progresses"."fetch_priority", "v2"."card_progresses"."deck_id", "v2"."card_progresses"."undo_data" FROM "v2"."card_progresses" WHERE "v2"."card_progresses"."note_id" = $1 AND "v2"."card_progresses"."ordinal" = $2 AND "v2"."card_progresses"."user_id" = $3
Covered by index on (note_id)
Rows: 112469624
Row progression: 112469624, 0

Row estimates
- note_id (=): 0
- user_id (=): 770
- ordinal (=): 112469624

Existing indexes
- id PRIMARY
- id, deck_id PRIMARY
- deck_id
- deck_id, id
- deck_id, user_id, note_id
- library_card_id
- library_note_id
- note_id
- user_id
- user_id, frozen
- user_id, id
- user_id, note_id
880 min 0.1% 0 ms 129,595,266 ankipro
SELECT "v2"."deck_settings"."id", "v2"."deck_settings"."algorithm_preset", "v2"."deck_settings"."deck_id", "v2"."deck_settings"."easy_interval_minutes", "v2"."deck_settings"."easy_bonus_percent", "v2"."deck_settings"."font_settings", "v2"."deck_settings"."graduated_interval_minutes", "v2"."deck_settings"."interval_modifier_percent", "v2"."deck_settings"."last_sync_at", "v2"."deck_settings"."library_sharing", "v2"."deck_settings"."new_cards_per_day", "v2"."deck_settings"."reverse_mode", "v2"."deck_settings"."offline_mode", "v2"."deck_settings"."sharing", "v2"."deck_settings"."steps_in_minutes", "v2"."deck_settings"."shuffle_mode", "v2"."deck_settings"."tts_autoplay", "v2"."deck_settings"."tts", "v2"."deck_settings"."tts_back_side_language", "v2"."deck_settings"."tts_front_side_language", "v2"."deck_settings"."user_id", "v2"."deck_settings"."created_at", "v2"."deck_settings"."updated_at", "v2"."deck_settings"."position", "v2"."deck_settings"."tts_whole_card_pronunciation", "v2"."deck_settings"."state", "v2"."deck_settings"."max_cards_per_day", "v2"."deck_settings"."card_preset_id", "v2"."deck_settings"."max_interval_minutes", "v2"."deck_settings"."tts_speed", "v2"."deck_settings"."tts_slower_replay", "v2"."deck_settings"."folder_id" FROM "v2"."deck_settings" WHERE "v2"."deck_settings"."deck_id" = $1 AND "v2"."deck_settings"."user_id" = $2 LIMIT $3
Covered by index on (deck_id)
Rows: 40252212
Row progression: 40252212, 1

Row estimates
- deck_id (=): 1
- user_id (=): 170

Existing indexes
- id PRIMARY
- id, deck_id PRIMARY
- deck_id
- deck_id
- folder_id
- user_id
- user_id
879 min 0.1% 2 ms 27,069,260 ankipro
SELECT "v2"."deck_settings"."deck_id" FROM "v2"."deck_settings" WHERE "v2"."deck_settings"."user_id" = $1 AND "v2"."deck_settings"."folder_id" = $2
849 min 0.1% 63 ms 813,861 ankipro
WITH subtree_decks AS ( SELECT id, ancestry FROM v2.decks WHERE (id IN ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21) OR ancestry LIKE $22 OR ancestry LIKE $23 OR ancestry LIKE $24 OR ancestry LIKE $25 OR ancestry LIKE $26 OR ancestry LIKE $27 OR ancestry LIKE $28 OR ancestry LIKE $29 OR ancestry LIKE $30 OR ancestry LIKE $31 OR ancestry LIKE $32 OR ancestry LIKE $33 OR ancestry LIKE $34 OR ancestry LIKE $35 OR ancestry LIKE $36 OR ancestry LIKE $37 OR ancestry LIKE $38 OR ancestry LIKE $39 OR ancestry LIKE $40 OR ancestry LIKE $41 OR ancestry LIKE $42) AND state NOT IN ($43,$44,$45) ), min_next_reviews AS ( SELECT deck_id, MIN(next_review_at) AS min_next_review_at FROM v2.card_progresses WHERE deck_id IN (SELECT id FROM subtree_decks) AND user_id = $46 AND frozen = $47 GROUP BY deck_id ) SELECT sd.id AS deck_id, sd.ancestry, mn.min_next_review_at FROM subtree_decks sd LEFT JOIN min_next_reviews mn ON sd.id = mn.deck_id
810 min 0.1% 0 ms 463,494,845 ankipro
UPDATE "users" SET "updated_at" = $1, "metadata" = $2 WHERE "users"."id" = $3
Covered by index on (id, timezone_offset)
Rows: 8717733
Row progression: 8717733, 1

Row estimates
- id (=): 1

Existing indexes
- id PRIMARY
- analytics_id
- country_code
- email varchar_pattern_ops
- id, timezone_offset
- locale, email WHERE (email IS NOT NULL) AND (onboarding_data IS NOT NULL) AND ((email)::text !~~ '%private%'::text)
- lower((email)::text)
- qon_id
- reset_password_token WHERE reset_password_token IS NOT NULL
- stripe_customer_id
- uid, provider UNIQUE
- username UNIQUE
798 min 0.1% 1 ms 62,958,630 ankipro
SELECT "v2"."card_progresses"."id" FROM "v2"."card_progresses" WHERE "v2"."card_progresses"."deck_id" = $1 AND "v2"."card_progresses"."user_id" = $2 AND "v2"."card_progresses"."frozen" = $3 AND (v2.card_progresses.next_review_at <= $4 OR v2.card_progresses.next_review_at IS NULL) AND (v2.card_progresses.to_learn_in_current_sl_round = $5 OR v2.card_progresses.to_learn_in_current_sl_round IS NULL) AND (learning_state IN ($6,$7,$8)) ORDER BY CASE v2.card_progresses.learning_state WHEN $9 THEN $10 WHEN $11 THEN $12 ELSE $13 END ASC, CASE WHEN v2.card_progresses.fetch_priority = $14 THEN $15 ELSE $16 END, RANDOM() LIMIT $17
797 min 0.1% 66 ms 726,399 ankipro
WITH subtree_decks AS ( SELECT id, ancestry FROM v2.decks WHERE (id IN ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22) OR ancestry LIKE $23 OR ancestry LIKE $24 OR ancestry LIKE $25 OR ancestry LIKE $26 OR ancestry LIKE $27 OR ancestry LIKE $28 OR ancestry LIKE $29 OR ancestry LIKE $30 OR ancestry LIKE $31 OR ancestry LIKE $32 OR ancestry LIKE $33 OR ancestry LIKE $34 OR ancestry LIKE $35 OR ancestry LIKE $36 OR ancestry LIKE $37 OR ancestry LIKE $38 OR ancestry LIKE $39 OR ancestry LIKE $40 OR ancestry LIKE $41 OR ancestry LIKE $42 OR ancestry LIKE $43 OR ancestry LIKE $44) AND state NOT IN ($45,$46,$47) ), min_next_reviews AS ( SELECT deck_id, MIN(next_review_at) AS min_next_review_at FROM v2.card_progresses WHERE deck_id IN (SELECT id FROM subtree_decks) AND user_id = $48 AND frozen = $49 GROUP BY deck_id ) SELECT sd.id AS deck_id, sd.ancestry, mn.min_next_review_at FROM subtree_decks sd LEFT JOIN min_next_reviews mn ON sd.id = mn.deck_id
760 min 0.1% 2 ms 22,143,889 ankipro
SELECT COUNT(id) AS total, SUM(CASE WHEN NOT frozen AND learning_state = $1 THEN $2 ELSE $3 END) AS new, SUM(CASE WHEN NOT frozen AND learning_state = $4 AND next_review_at < $5 THEN $6 ELSE $7 END) AS learning, SUM(CASE WHEN NOT frozen AND learning_state = $8 AND next_review_at < $9 THEN $10 ELSE $11 END) AS graduated, SUM(CASE WHEN NOT frozen AND learning_state = $12 THEN $13 ELSE $14 END) AS learning_total, SUM(CASE WHEN NOT frozen AND learning_state = $15 THEN $16 ELSE $17 END) AS graduated_total, SUM(CASE WHEN NOT frozen AND learning_state = $18 THEN $19 ELSE $20 END) AS study_again, SUM(CASE WHEN NOT frozen AND learning_state = $21 THEN $22 ELSE $23 END) AS got_it, SUM(CASE WHEN frozen THEN $24 ELSE $25 END) as frozen, SUM(CASE WHEN NOT frozen AND learning_state IN($26, $27, $28) AND next_review_at < $29 THEN $30 ELSE $31 END) as offline_available, MIN(CASE WHEN NOT frozen AND next_review_at > $32 THEN next_review_at ELSE $33 END) as recalculate_at FROM v2.card_progresses WHERE user_id = $34 AND deck_id IN ($35,$36)
Covered by index on (deck_id, user_id, note_id)
Rows: 112469624
Row progression: 112469624, 273, 0

Row estimates
- deck_id (=): 273
- user_id (=): 770

Existing indexes
- id PRIMARY
- id, deck_id PRIMARY
- deck_id
- deck_id, id
- deck_id, user_id, note_id
- library_card_id
- library_note_id
- note_id
- user_id
- user_id, frozen
- user_id, id
- user_id, note_id
724 min 0.1% 1 ms 66,118,338 ankipro
UPDATE "v2"."card_progresses" SET "ease_factor" = $1, "interval" = $2, "next_review_at" = $3, "raw_next_review_at" = $4, "updated_at" = $5, "undo_data" = $6 WHERE "v2"."card_progresses"."id" = $7 AND "v2"."card_progresses"."deck_id" = $8
Covered by index on (id)
Rows: 112469624
Row progression: 112469624, 1

Row estimates
- id (=): 1
- deck_id (=): 273

Existing indexes
- id PRIMARY
- id, deck_id PRIMARY
- deck_id
- deck_id, id
- deck_id, user_id, note_id
- library_card_id
- library_note_id
- note_id
- user_id
- user_id, frozen
- user_id, id
- user_id, note_id
721 min 0.1% 77 ms 558,554 ankipro
SELECT "v2"."decks"."id", "v2"."decks"."deck_collaborators_count", "v2"."decks"."deleted_by_user_at", "v2"."decks"."downvotes", "v2"."decks"."import_error_message", "v2"."decks"."name", "v2"."decks"."last_reset_at", "v2"."decks"."public_state", "v2"."decks"."sharing_token", "v2"."decks"."state", "v2"."decks"."visibility", "v2"."decks"."upvotes", "v2"."decks"."user_id", "v2"."decks"."created_at", "v2"."decks"."updated_at", "v2"."decks"."ancestry", "v2"."decks"."slug", "v2"."decks"."seo_description", "v2"."decks"."description", "v2"."decks"."category", "v2"."decks"."cloned_times_count", "v2"."decks"."is_indexable", "v2"."decks"."study_score", "v2"."decks"."library_deck_id", "v2"."decks"."file_hash", "v2"."decks"."cloned_from_id", "v2"."decks"."anki_deck_id", "v2"."decks"."studiers_count", "v2"."decks"."deck_id", "v2"."decks"."moved_at", "v2"."decks"."source", "v2"."decks"."reviews_count", "v2"."decks"."duplicated_from_id", "v2"."decks"."no_cards_limit", "v2"."decks"."category_id" FROM "v2"."decks" WHERE "v2"."decks"."user_id" IN ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35, $36, $37, $38, $39, $40, $41, $42, $43, $44, $45, $46, $47, $48, $49, $50, $51, $52, $53, $54, $55, $56, $57, $58, $59, $60, $61, $62, $63, $64, $65, $66, $67, $68, $69, $70, $71, $72, $73, $74, $75, $76, $77, $78, $79, $80, $81, $82, $83, $84, $85, $86, $87, $88, $89, $90, $91, $92, $93, $94, $95, $96, $97, $98, $99, $100, $101, $102, $103, $104, $105, $106, $107, $108, $109, $110, $111, $112, $113, $114, $115, $116, $117, $118, $119, $120, $121, $122, $123, $124, $125, $126, $127, $128, $129, $130, $131, $132, $133, $134, $135, $136, $137, $138, $139, $140, $141, $142, $143, $144, $145, $146, $147, $148, $149, $150, $151, $152, $153, $154, $155, $156, $157, $158, $159, $160, $161, $162, $163, $164, $165, $166, $167, $168, $169, $170, $171, $172, $173, $174, $175, $176, $177, $178, $179, $180, $181, $182, $183, $184, $185, $186, $187, $188, $189, $190, $191, $192, $193, $194, $195, $196, $197, $198, $199, $200, $201, $202, $203, $204, $205, $206, $207, $208, $209, $210, $211, $212, $213, $214, $215, $216, $217, $218, $219, $220, $221, $222, $223, $224, $225, $226, $227, $228, $229, $230, $231, $232, $233, $234, $235, $236, $237, $238, $239, $240, $241, $242, $243, $244, $245, $246, $247, $248, $249, $250, $251, $252, $253, $254, $255, $256, $257, $258, $259, $260, $261, $262, $263, $264, $265, $266, $267, $268, $269, $270, $271, $272, $273, $274, $275, $276, $277, $278, $279, $280, $281, $282, $283, $284, $285, $286, $287, $288, $289, $290, $291, $292, $293, $294, $295, $296, $297, $298, $299, $300, $301, $302, $303, $304, $305, $306, $307, $308, $309, $310, $311, $312, $313, $314, $315, $316, $317, $318, $319, $320, $321, $322, $323, $324, $325, $326, $327, $328, $329, $330, $331, $332, $333, $334, $335, $336, $337, $338, $339, $340, $341, $342, $343, $344, $345, $346, $347, $348, $349, $350, $351, $352, $353, $354, $355, $356, $357, $358, $359, $360, $361, $362, $363, $364, $365, $366, $367, $368, $369, $370, $371, $372, $373, $374, $375, $376, $377, $378, $379, $380, $381, $382, $383, $384, $385, $386, $387, $388, $389, $390, $391, $392, $393, $394, $395, $396, $397, $398, $399, $400, $401, $402, $403, $404, $405, $406, $407, $408, $409, $410, $411, $412, $413, $414, $415, $416, $417, $418, $419, $420, $421, $422, $423, $424, $425, $426, $427, $428, $429, $430, $431, $432, $433, $434, $435, $436, $437, $438, $439, $440, $441, $442, $443, $444, $445, $446, $447, $448, $449, $450, $451, $452, $453, $454, $455, $456, $457, $458, $459, $460, $461, $462, $463, $464, $465, $466, $467, $468, $469, $470, $471, $472, $473, $474, $475, $476, $477, $478, $479, $480, $481, $482, $483, $484, $485, $486, $487, $488, $489, $490, $491, $492, $493, $494, $495, $496, $497, $498, $499, $500)
Covered by index on (user_id)
Rows: 40047676
Row progression: 40047676, 155

Row estimates
- user_id (=): 155

Existing indexes
- id PRIMARY
- id, user_id PRIMARY
- ancestry
- ancestry text_pattern_ops
- ancestry varchar_pattern_ops
- anki_deck_id
- category_id
- cloned_from_id
- deck_import_id
- deleted_by_user_at, user_id
- id, state
- library_deck_id
- public_state, visibility
- sharing_token varchar_pattern_ops UNIQUE
- state
- user_id
- user_id
718 min 0.1% 31 ms 1,401,297 ankipro
WITH LatestCardProgress AS ( SELECT DISTINCT ON (cp.note_id) cp.note_id, cp.next_review_at, cp.learning_state FROM v2.card_progresses AS cp WHERE cp.user_id = $1 AND cp.deck_id IN ($2) ORDER BY cp.note_id, cp.next_review_at ASC NULLS LAST ) SELECT notes.id,notes.deck_id,notes.template_kind,notes.fields, notes.cards_count, notes.css, notes.created_at FROM v2.notes AS notes JOIN LatestCardProgress AS lcp ON lcp.note_id = notes.id WHERE notes.deck_id IN ($3) ORDER BY lcp.next_review_at ASC NULLS LAST, notes.id ASC OFFSET $4 LIMIT $5
708 min 0.1% 65 ms 651,543 ankipro
WITH subtree_decks AS ( SELECT id, ancestry FROM v2.decks WHERE (id IN ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23) OR ancestry LIKE $24 OR ancestry LIKE $25 OR ancestry LIKE $26 OR ancestry LIKE $27 OR ancestry LIKE $28 OR ancestry LIKE $29 OR ancestry LIKE $30 OR ancestry LIKE $31 OR ancestry LIKE $32 OR ancestry LIKE $33 OR ancestry LIKE $34 OR ancestry LIKE $35 OR ancestry LIKE $36 OR ancestry LIKE $37 OR ancestry LIKE $38 OR ancestry LIKE $39 OR ancestry LIKE $40 OR ancestry LIKE $41 OR ancestry LIKE $42 OR ancestry LIKE $43 OR ancestry LIKE $44 OR ancestry LIKE $45 OR ancestry LIKE $46) AND state NOT IN ($47,$48,$49) ), min_next_reviews AS ( SELECT deck_id, MIN(next_review_at) AS min_next_review_at FROM v2.card_progresses WHERE deck_id IN (SELECT id FROM subtree_decks) AND user_id = $50 AND frozen = $51 GROUP BY deck_id ) SELECT sd.id AS deck_id, sd.ancestry, mn.min_next_review_at FROM subtree_decks sd LEFT JOIN min_next_reviews mn ON sd.id = mn.deck_id
705 min 0.1% 0 ms 101,182,197 ankipro
UPDATE "v2"."deck_counters" SET "updated_at" = $1 WHERE "v2"."deck_counters"."id" = $2 AND "v2"."deck_counters"."deck_id" = $3
Covered by index on (id)
Rows: 40145496
Row progression: 40145496, 1

Row estimates
- id (=): 1
- deck_id (=): 1

Existing indexes
- id PRIMARY
- id, deck_id PRIMARY
- deck_id
- deck_id, user_id UNIQUE
- user_id
- user_id
703 min 0.1% 0 ms 2,161,643,068 ankipro
SELECT "subscriptions"."id", "subscriptions"."user_id", "subscriptions"."platform", "subscriptions"."pricing_tier", "subscriptions"."product_id", "subscriptions"."is_pending", "subscriptions"."is_sandbox", "subscriptions"."expires_at", "subscriptions"."created_at", "subscriptions"."updated_at", "subscriptions"."stripe_payment_intent_id", "subscriptions"."stripe_subscription_id", "subscriptions"."comment", "subscriptions"."price", "subscriptions"."currency", "subscriptions"."coupon" FROM "subscriptions" WHERE "subscriptions"."user_id" = $1 AND (expires_at > $2) ORDER BY "subscriptions"."id" DESC LIMIT $3
Covered by index on (user_id)
Rows: 216605
Row progression: 216605, 2

Row estimates
- user_id (=): 2
- expires_at (>): 12760
- id (sort): 1

Existing indexes
- id PRIMARY
- product_id
- user_id