Skip to content

Instantly share code, notes, and snippets.

@lfittl
Created September 3, 2009 17:17
Show Gist options
  • Select an option

  • Save lfittl/180403 to your computer and use it in GitHub Desktop.

Select an option

Save lfittl/180403 to your computer and use it in GitHub Desktop.
Table "public.posts"
Column | Type | Modifiers
---------------------+--------------------------+----------------------------------------------------
id | bigint | not null default nextval('posts_id_seq'::regclass)
created_at | timestamp with time zone | not null default now()
updated_at | timestamp with time zone |
type | post_type |
deleted | boolean | not null default false
blog_id | bigint |
author_id | integer |
asset_id | bigint |
feed_id | bigint |
parent_id | bigint |
original_id | bigint |
edited_after_repost | boolean |
inappropriateness | real | default 0.0
language | regconfig | default 'simple'::regconfig
guid | text |
source | text |
Indexes:
"posts_pkey1" PRIMARY KEY, btree (id)
"posts_asset_id" btree (asset_id)
"posts_blog_id" btree (blog_id)
"posts_feed_id_created_at" btree (feed_id, created_at)
"posts_feed_id_source" btree (feed_id, source)
"posts_for_friendposts" btree (created_at, id, blog_id, author_id)
"posts_for_friendposts2" btree (blog_id, created_at, id)
"posts_for_one_soup" btree (blog_id, created_at, id) WHERE language IS NOT NULL
"posts_for_original_rss" btree (blog_id, created_at, id) WHERE feed_id IS NULL
"posts_frontpage" btree (created_at, id, feed_id) WHERE parent_id IS NULL
"posts_guid_feed_id" btree (guid, feed_id)
"posts_repost_info" btree (original_id, created_at)
Foreign-key constraints:
"fk_posts_assets" FOREIGN KEY (asset_id) REFERENCES assets(id) ON DELETE SET NULL
"fk_posts_authors" FOREIGN KEY (author_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE
"fk_posts_blogs" FOREIGN KEY (blog_id) REFERENCES blogs(id) ON UPDATE CASCADE ON DELETE CASCADE
Triggers:
maintain_post_feed_info AFTER INSERT OR UPDATE ON posts FOR EACH ROW EXECUTE PROCEDURE maintain_post_feed_info_trigger()
refresh_events_for_calendar AFTER UPDATE ON posts FOR EACH ROW EXECUTE PROCEDURE refresh_events_for_calendar()
refresh_taggings AFTER UPDATE ON posts FOR EACH ROW EXECUTE PROCEDURE refresh_taggings()
SELECT posts.id FROM posts WHERE posts.blog_id IN (134368,136333,136043,134837,144282,142198,134939,140991,134222,134158,142307,142012,142154,140746,140586,137319,138615,140870,138400,140353,134166,140437,138984,139962,139804,136704,134196,138305,135312,137821,136401,138154,135297,138358,135028,137449,134756,135892,138312,134105,135529,137476,137521,136381,136005,134700,134288,134263,136394,135117,134938,137192,134630,136807,136787,135505,136589,134209,135420,135010,134165,134541,135575,135987,134243,136687,134220,134225,134219,134267,134283,135877,134951,134955,135315,134163,134237,134320,134890,134119,136390,136406,134128,136332,135851,134162,134112,134124,136379,136359,134109,134156,135989,134239,136229,135278,136393,134327,136403,136342,134136,136395,134968,134134,136405,136188,134922,134101,135030,134104,134576,134121,134157,135216,123374,136106,136398,134103,136203,136337,134223,136385,134125,134145,134164,134221,134153,134111,135890,134117,134632,136162,134893,134204,134144,134214,134991,134206,134224,134147,134228,134118) ORDER BY posts.created_at DESC, posts.id DESC LIMIT 40
Limit (cost=0.00..1231.04 rows=40 width=16)
-> Index Scan Backward using posts_for_friendposts on posts (cost=0.00..2997862.98 rows=97409 width=16)
Filter: (blog_id = ANY ('{134368,136333,136043,134837,144282,142198,134939,140991,134222,134158,142307,142012,142154,140746,140586,137319,138615,140870,138400,140353,134166,140437,138984,139962,139804,136704,134196,138305,135312,137821,136401,138154,135297,138358,135028,137449,134756,135892,138312,134105,135529,137476,137521,136381,136005,134700,134288,134263,136394,135117,134938,137192,134630,136807,136787,135505,136589,134209,135420,135010,134165,134541,135575,135987,134243,136687,134220,134225,134219,134267,134283,135877,134951,134955,135315,134163,134237,134320,134890,134119,136390,136406,134128,136332,135851,134162,134112,134124,136379,136359,134109,134156,135989,134239,136229,135278,136393,134327,136403,136342,134136,136395,134968,134134,136405,136188,134922,134101,135030,134104,134576,134121,134157,135216,123374,136106,136398,134103,136203,136337,134223,136385,134125,134145,134164,134221,134153,134111,135890,134117,134632,136162,134893,134204,134144,134214,134991,134206,134224,134147,134228,134118}'::bigint[]))
(3 rows)
Limit (cost=0.00..1231.04 rows=40 width=16) (actual time=21847.259..154613.339 rows=40 loops=1)
-> Index Scan Backward using posts_for_friendposts on posts (cost=0.00..2997862.98 rows=97409 width=16) (actual time=21847.258..154613.306 rows=40 loops=1)
Filter: (blog_id = ANY ('{134368,136333,136043,134837,144282,142198,134939,140991,134222,134158,142307,142012,142154,140746,140586,137319,138615,140870,138400,140353,134166,140437,138984,139962,139804,136704,134196,138305,135312,137821,136401,138154,135297,138358,135028,137449,134756,135892,138312,134105,135529,137476,137521,136381,136005,134700,134288,134263,136394,135117,134938,137192,134630,136807,136787,135505,136589,134209,135420,135010,134165,134541,135575,135987,134243,136687,134220,134225,134219,134267,134283,135877,134951,134955,135315,134163,134237,134320,134890,134119,136390,136406,134128,136332,135851,134162,134112,134124,136379,136359,134109,134156,135989,134239,136229,135278,136393,134327,136403,136342,134136,136395,134968,134134,136405,136188,134922,134101,135030,134104,134576,134121,134157,135216,123374,136106,136398,134103,136203,136337,134223,136385,134125,134145,134164,134221,134153,134111,135890,134117,134632,136162,134893,134204,134144,134214,134991,134206,134224,134147,134228,134118}'::bigint[]))
Total runtime: 154613.446 ms
id | created_at
----------+-------------------------------
26697788 | 2009-08-28 08:42:34.425286+00
26294198 | 2009-08-24 07:42:04.734289+00
26294149 | 2009-08-24 07:41:25.59292+00
26084583 | 2009-08-21 07:40:14.140545+00
25377905 | 2009-08-13 10:05:20.915222+00
25377867 | 2009-08-13 10:04:29.139352+00
25334265 | 2009-08-12 21:18:09.544952+00
25181303 | 2009-08-11 08:00:14.566219+00
25181221 | 2009-08-11 07:58:22.237423+00
24883456 | 2009-08-07 09:20:06.98623+00
24883430 | 2009-08-07 09:19:08.702244+00
23839624 | 2009-07-24 05:19:31.905917+00
23274744 | 2009-07-15 15:23:34.100147+00
22968246 | 2009-07-10 19:24:56.299826+00
22805794 | 2009-07-08 08:21:55.453885+00
22598419 | 2009-07-04 14:38:59.410779+00
22597580 | 2009-07-04 14:16:20.022121+00
22568816 | 2009-07-03 21:58:18.749561+00
22435230 | 2009-07-01 19:54:12.18948+00
22434889 | 2009-07-01 19:48:18.933857+00
22413556 | 2009-07-01 15:01:30.429335+00
22356708 | 2009-06-30 21:40:12.842712+00
22355766 | 2009-06-30 21:25:57.94321+00
22354828 | 2009-06-30 21:10:01.470273+00
22354691 | 2009-06-30 21:07:28.269385+00
22352785 | 2009-06-30 20:38:12.513735+00
22352235 | 2009-06-30 20:28:12.539029+00
22352155 | 2009-06-30 20:27:35.794752+00
22352127 | 2009-06-30 20:26:57.477663+00
22351904 | 2009-06-30 20:19:31.892036+00
22351898 | 2009-06-30 20:19:29.963081+00
22351732 | 2009-06-30 20:17:10.146601+00
22351500 | 2009-06-30 20:13:36.673707+00
22350519 | 2009-06-30 19:54:44.780425+00
22348308 | 2009-06-30 19:08:57.587012+00
22348075 | 2009-06-30 19:06:59.264287+00
22347697 | 2009-06-30 18:58:20.241194+00
22346800 | 2009-06-30 18:41:00.260411+00
22346306 | 2009-06-30 18:27:56.454293+00
22346258 | 2009-06-30 18:27:21.171221+00
Limit (cost=159851.05..159851.07 rows=40 width=16) (actual time=14253.264..14253.275 rows=40 loops=1)
-> Sort (cost=159851.05..159899.76 rows=97409 width=16) (actual time=14253.263..14253.269 rows=40 loops=1)
Sort Key: created_at, id
Sort Method: top-N heapsort Memory: 26kB
-> Bitmap Heap Scan on posts (cost=1294.62..159235.24 rows=97409 width=16) (actual time=442.928..14249.903 rows=4208 loops=1)
Recheck Cond: (blog_id = ANY ('{134368,136333,136043,134837,144282,142198,134939,140991,134222,134158,142307,142012,142154,140746,140586,137319,138615,140870,138400,140353,134166,140437,138984,139962,139804,136704,134196,138305,135312,137821,136401,138154,135297,138358,135028,137449,134756,135892,138312,134105,135529,137476,137521,136381,136005,134700,134288,134263,136394,135117,134938,137192,134630,136807,136787,135505,136589,134209,135420,135010,134165,134541,135575,135987,134243,136687,134220,134225,134219,134267,134283,135877,134951,134955,135315,134163,134237,134320,134890,134119,136390,136406,134128,136332,135851,134162,134112,134124,136379,136359,134109,134156,135989,134239,136229,135278,136393,134327,136403,136342,134136,136395,134968,134134,136405,136188,134922,134101,135030,134104,134576,134121,134157,135216,123374,136106,136398,134103,136203,136337,134223,136385,134125,134145,134164,134221,134153,134111,135890,134117,134632,136162,134893,134204,134144,134214,134991,134206,134224,134147,134228,134118}'::bigint[]))
-> Bitmap Index Scan on posts_for_friendposts2 (cost=0.00..1289.75 rows=97409 width=0) (actual time=441.964..441.964 rows=4208 loops=1)
Index Cond: (blog_id = ANY ('{134368,136333,136043,134837,144282,142198,134939,140991,134222,134158,142307,142012,142154,140746,140586,137319,138615,140870,138400,140353,134166,140437,138984,139962,139804,136704,134196,138305,135312,137821,136401,138154,135297,138358,135028,137449,134756,135892,138312,134105,135529,137476,137521,136381,136005,134700,134288,134263,136394,135117,134938,137192,134630,136807,136787,135505,136589,134209,135420,135010,134165,134541,135575,135987,134243,136687,134220,134225,134219,134267,134283,135877,134951,134955,135315,134163,134237,134320,134890,134119,136390,136406,134128,136332,135851,134162,134112,134124,136379,136359,134109,134156,135989,134239,136229,135278,136393,134327,136403,136342,134136,136395,134968,134134,136405,136188,134922,134101,135030,134104,134576,134121,134157,135216,123374,136106,136398,134103,136203,136337,134223,136385,134125,134145,134164,134221,134153,134111,135890,134117,134632,136162,134893,134204,134144,134214,134991,134206,134224,134147,134228,134118}'::bigint[]))
Total runtime: 14253.327 ms
Total runtime (2. Mal): 11.192 ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment