File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change 11-- These are the optional post processing tasks which may be performed.
22
33-- UserTagQA TABLE
4+ -- How many Questions and Answers has the user posted under a given tag.
45DROP TABLE IF EXISTS UserTagQA;
56CREATE TABLE UserTagQA (
67 UserId int ,
@@ -12,16 +13,18 @@ CREATE TABLE UserTagQA (
1213INSERT INTO UserTagQA
1314 ( SELECT P .ownerUserId AS UserId,
1415 PT .tagId AS TagId,
15- sum (CASE P .PostTypeId WHEN 1 THEN 1 ELSE 0 END) AS Questions,
16- sum (CASE P .PostTypeId WHEN 2 THEN 1 ELSE 0 END) AS Answers
17- FROM Posts P JOIN PostTags PT ON PT .PostId = P .Id
16+ SUM (CASE P .PostTypeId WHEN 1 THEN 1 ELSE 0 END) AS Questions,
17+ SUM (CASE P .PostTypeId WHEN 2 THEN 1 ELSE 0 END) AS Answers
18+ FROM Posts P JOIN PostTags PT ON ( PT .PostId = P .Id OR PT . PostId = P . ParentId )
1819 WHERE P .OwnerUserId IS NOT NULL
1920 GROUP BY P .OwnerUserId , PT .TagId
2021 );
2122CREATE INDEX usertagqa_questions_idx ON UserTagQA USING btree (Questions)
2223 WITH (FILLFACTOR = 100 );
2324CREATE INDEX usertagqa_answers_idx ON UserTagQA USING btree (Answers)
2425 WITH (FILLFACTOR = 100 );
26+ CREATE INDEX usertagqa_questions_answers_idx ON UserTagQA USING btree (Questions, Answers)
27+ WITH (FILLFACTOR = 100 );
2528
2629
2730-- QuestionAnswer TABLE
You can’t perform that action at this time.
0 commit comments