query-planner

Why Mongo query for null filters in FETCH after performing IXSCAN

Deadly 提交于 2020-01-15 11:53:37
问题 According to Mongo Documentation, The { item : null } query matches documents that either contain the item field whose value is null or that do not contain the item field. I can't find documentation for this, but as far as I can tell, both cases (value is null or field is missing) are stored in the index as null . So if I do db.orders.createIndex({item: 1}) and then db.orders.find({item: null}) , I would expect an IXSCAN to find all documents that either contain the item field whose value is

Why Mongo query for null filters in FETCH after performing IXSCAN

南楼画角 提交于 2020-01-15 11:52:59
问题 According to Mongo Documentation, The { item : null } query matches documents that either contain the item field whose value is null or that do not contain the item field. I can't find documentation for this, but as far as I can tell, both cases (value is null or field is missing) are stored in the index as null . So if I do db.orders.createIndex({item: 1}) and then db.orders.find({item: null}) , I would expect an IXSCAN to find all documents that either contain the item field whose value is

why the query is executed 76 times slower when I put it into function?

不打扰是莪最后的温柔 提交于 2019-12-11 06:06:20
问题 When I put next query into function it goes 76times slower. The only difference at plan is: bitmap-index scan VS index scan Plan1: http://tatiyants.com/pev/#/plans/plan_1562919134481 Plan2: http://tatiyants.com/pev/#/plans/plan_1562918860704 plan1 EXPLAIN (ANALYZE, COSTS, VERBOSE, BUFFERS, FORMAT JSON) SELECT sum( t.group_suma ) OVER( PARTITION BY (t.o).id ) AS total_suma, * FROM ( SELECT sum( ocd.item_cost ) AS group_cost, sum( ocd.item_suma ) AS group_suma, max( (ocd.ic).consumed ) AS

Query plan caching with pl/pgsql

最后都变了- 提交于 2019-11-30 22:01:33
I am having troubles understanding how the query plan caching works for pl/pgsql. I want to built all-in-one queries with JOIN s and IF s, so I will have multiple and different query parameters, and I will be searching in more that one tables. At first I thought that using pl/pgsql will produce a different plan for each parameters combination, that is not the case, because I have more than one tables SQL commands that appear directly in a PL/pgSQL function must refer to the same tables and columns on every execution; that is, you cannot use a parameter as the name of a table or column in an

Query plan caching with pl/pgsql

大兔子大兔子 提交于 2019-11-30 17:26:46
问题 I am having troubles understanding how the query plan caching works for pl/pgsql. I want to built all-in-one queries with JOIN s and IF s, so I will have multiple and different query parameters, and I will be searching in more that one tables. At first I thought that using pl/pgsql will produce a different plan for each parameters combination, that is not the case, because I have more than one tables SQL commands that appear directly in a PL/pgSQL function must refer to the same tables and