mirror of https://github.com/citusdata/citus.git
Remove unnecessary copying of shard interval list
This commit removes unnecessary copying of shard interval list. Note that there are no copyObject function implemented for shard intervals.pull/1342/head
parent
30637baa68
commit
6dd27f3df9
|
@ -2996,10 +2996,10 @@ InsertSelectQuery(Query *query)
|
||||||
* shallowly, for lack of copyObject support.
|
* shallowly, for lack of copyObject support.
|
||||||
*
|
*
|
||||||
* Note that CopyRelationRestrictionContext copies the following fields per relation
|
* Note that CopyRelationRestrictionContext copies the following fields per relation
|
||||||
* context: index, relationId, distributedRelation, rte, relOptInfo->baserestrictinfo,
|
* context: index, relationId, distributedRelation, rte, relOptInfo->baserestrictinfo
|
||||||
* relOptInfo->joininfo and prunedShardIntervalList. Also, the function shallowly copies
|
* and relOptInfo->joininfo. Also, the function shallowly copies plannerInfo and
|
||||||
* plannerInfo which is read-only. All other parts of the relOptInfo is also shallowly
|
* prunedShardIntervalList which are read-only. All other parts of the relOptInfo
|
||||||
* copied.
|
* is also shallowly copied.
|
||||||
*/
|
*/
|
||||||
RelationRestrictionContext *
|
RelationRestrictionContext *
|
||||||
CopyRelationRestrictionContext(RelationRestrictionContext *oldContext)
|
CopyRelationRestrictionContext(RelationRestrictionContext *oldContext)
|
||||||
|
@ -3038,8 +3038,7 @@ CopyRelationRestrictionContext(RelationRestrictionContext *oldContext)
|
||||||
|
|
||||||
/* not copyable, but readonly */
|
/* not copyable, but readonly */
|
||||||
newRestriction->plannerInfo = oldRestriction->plannerInfo;
|
newRestriction->plannerInfo = oldRestriction->plannerInfo;
|
||||||
newRestriction->prunedShardIntervalList =
|
newRestriction->prunedShardIntervalList = oldRestriction->prunedShardIntervalList;
|
||||||
copyObject(oldRestriction->prunedShardIntervalList);
|
|
||||||
|
|
||||||
newContext->relationRestrictionList =
|
newContext->relationRestrictionList =
|
||||||
lappend(newContext->relationRestrictionList, newRestriction);
|
lappend(newContext->relationRestrictionList, newRestriction);
|
||||||
|
|
|
@ -568,9 +568,16 @@ SELECT user_id FROM recent_selected_users GROUP BY 1 ORDER BY 1;
|
||||||
(12 rows)
|
(12 rows)
|
||||||
|
|
||||||
-- this would be supported when we implement where partition_key in (subquery) support
|
-- this would be supported when we implement where partition_key in (subquery) support
|
||||||
SELECT et.* FROM events_table et WHERE et.user_id IN (SELECT user_id FROM recent_selected_users);
|
SELECT et.user_id, et.time FROM events_table et WHERE et.user_id IN (SELECT user_id FROM recent_selected_users) GROUP BY 1,2 ORDER BY 1 DESC,2 DESC LIMIT 5;
|
||||||
ERROR: could not run distributed query with subquery outside the FROM clause
|
user_id | time
|
||||||
HINT: Consider using an equality filter on the distributed table's partition column.
|
---------+---------------------------------
|
||||||
|
90 | Tue Jan 21 02:50:05.379732 2014
|
||||||
|
90 | Tue Jan 21 00:08:33.911898 2014
|
||||||
|
90 | Mon Jan 20 22:25:39.21906 2014
|
||||||
|
90 | Mon Jan 20 21:11:10.814326 2014
|
||||||
|
90 | Mon Jan 20 19:16:33.359257 2014
|
||||||
|
(5 rows)
|
||||||
|
|
||||||
-- it is supported when it is a router query
|
-- it is supported when it is a router query
|
||||||
SELECT count(*) FROM events_table et WHERE et.user_id IN (SELECT user_id FROM recent_selected_users WHERE user_id = 90);
|
SELECT count(*) FROM events_table et WHERE et.user_id IN (SELECT user_id FROM recent_selected_users WHERE user_id = 90);
|
||||||
count
|
count
|
||||||
|
@ -725,18 +732,23 @@ SELECT user_id FROM router_view GROUP BY 1;
|
||||||
2
|
2
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
-- There is a known issue with router plannable subqueries joined with non-router
|
-- join a router view
|
||||||
-- plannable subqueries. Following tests should be uncommented when we fix it
|
SELECT * FROM (SELECT user_id FROM router_view GROUP BY 1) rv JOIN recent_events USING (user_id) ORDER BY 2 LIMIT 3;
|
||||||
-- join a router view (not implement error)
|
user_id | time
|
||||||
-- SELECT * FROM (SELECT user_id FROM router_view GROUP BY 1) rv JOIN recent_events USING (user_id);
|
---------+---------------------------------
|
||||||
-- it still does not work when converted to 2 subquery join
|
2 | Mon Jan 20 02:02:03.208351 2014
|
||||||
-- SELECT * FROM (SELECT user_id FROM router_view GROUP BY 1) rv JOIN (SELECT * FROM recent_events) re USING (user_id);
|
2 | Mon Jan 20 02:34:14.54301 2014
|
||||||
-- views are completely removed and still it does not work
|
2 | Mon Jan 20 03:16:38.418772 2014
|
||||||
-- SELECT * FROM
|
(3 rows)
|
||||||
-- (SELECT user_id FROM (SELECT * FROM users_table WHERE user_id = 2) rv1 GROUP BY 1) rv2
|
|
||||||
-- JOIN (SELECT user_id, time FROM events_table
|
SELECT * FROM (SELECT user_id FROM router_view GROUP BY 1) rv JOIN (SELECT * FROM recent_events) re USING (user_id) ORDER BY 2 LIMIT 3;
|
||||||
-- WHERE time > '2014-01-20 01:45:49.978738'::timestamp) re
|
user_id | time
|
||||||
-- USING (user_id);
|
---------+---------------------------------
|
||||||
|
2 | Mon Jan 20 02:02:03.208351 2014
|
||||||
|
2 | Mon Jan 20 02:34:14.54301 2014
|
||||||
|
2 | Mon Jan 20 03:16:38.418772 2014
|
||||||
|
(3 rows)
|
||||||
|
|
||||||
-- views with limits
|
-- views with limits
|
||||||
CREATE VIEW recent_10_users AS
|
CREATE VIEW recent_10_users AS
|
||||||
SELECT user_id, max(time) as lastseen FROM users_table
|
SELECT user_id, max(time) as lastseen FROM users_table
|
||||||
|
|
|
@ -259,7 +259,7 @@ CREATE VIEW recent_selected_users AS SELECT su.* FROM selected_users su JOIN rec
|
||||||
SELECT user_id FROM recent_selected_users GROUP BY 1 ORDER BY 1;
|
SELECT user_id FROM recent_selected_users GROUP BY 1 ORDER BY 1;
|
||||||
|
|
||||||
-- this would be supported when we implement where partition_key in (subquery) support
|
-- this would be supported when we implement where partition_key in (subquery) support
|
||||||
SELECT et.* FROM events_table et WHERE et.user_id IN (SELECT user_id FROM recent_selected_users);
|
SELECT et.user_id, et.time FROM events_table et WHERE et.user_id IN (SELECT user_id FROM recent_selected_users) GROUP BY 1,2 ORDER BY 1 DESC,2 DESC LIMIT 5;
|
||||||
|
|
||||||
-- it is supported when it is a router query
|
-- it is supported when it is a router query
|
||||||
SELECT count(*) FROM events_table et WHERE et.user_id IN (SELECT user_id FROM recent_selected_users WHERE user_id = 90);
|
SELECT count(*) FROM events_table et WHERE et.user_id IN (SELECT user_id FROM recent_selected_users WHERE user_id = 90);
|
||||||
|
@ -351,21 +351,9 @@ CREATE VIEW router_view AS SELECT * FROM users_table WHERE user_id = 2;
|
||||||
-- router plannable
|
-- router plannable
|
||||||
SELECT user_id FROM router_view GROUP BY 1;
|
SELECT user_id FROM router_view GROUP BY 1;
|
||||||
|
|
||||||
-- There is a known issue with router plannable subqueries joined with non-router
|
-- join a router view
|
||||||
-- plannable subqueries. Following tests should be uncommented when we fix it
|
SELECT * FROM (SELECT user_id FROM router_view GROUP BY 1) rv JOIN recent_events USING (user_id) ORDER BY 2 LIMIT 3;
|
||||||
|
SELECT * FROM (SELECT user_id FROM router_view GROUP BY 1) rv JOIN (SELECT * FROM recent_events) re USING (user_id) ORDER BY 2 LIMIT 3;
|
||||||
-- join a router view (not implement error)
|
|
||||||
-- SELECT * FROM (SELECT user_id FROM router_view GROUP BY 1) rv JOIN recent_events USING (user_id);
|
|
||||||
|
|
||||||
-- it still does not work when converted to 2 subquery join
|
|
||||||
-- SELECT * FROM (SELECT user_id FROM router_view GROUP BY 1) rv JOIN (SELECT * FROM recent_events) re USING (user_id);
|
|
||||||
|
|
||||||
-- views are completely removed and still it does not work
|
|
||||||
-- SELECT * FROM
|
|
||||||
-- (SELECT user_id FROM (SELECT * FROM users_table WHERE user_id = 2) rv1 GROUP BY 1) rv2
|
|
||||||
-- JOIN (SELECT user_id, time FROM events_table
|
|
||||||
-- WHERE time > '2014-01-20 01:45:49.978738'::timestamp) re
|
|
||||||
-- USING (user_id);
|
|
||||||
|
|
||||||
-- views with limits
|
-- views with limits
|
||||||
CREATE VIEW recent_10_users AS
|
CREATE VIEW recent_10_users AS
|
||||||
|
|
Loading…
Reference in New Issue