- 
                Notifications
    You must be signed in to change notification settings 
- Fork 15
Selectivity estimators for <@(spoint, scircle) and spoint_dwithin(spoint, spoint, float8) #80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
    
  
     Merged
                    Changes from all commits
      Commits
    
    
  File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,155 @@ | ||
| -- spoint_dwithin function selectivity | ||
| set jit = off; -- suppress extra planning output | ||
| select explain('select * from spoint10k where spoint_dwithin(star, spoint(1,1), 1)'); | ||
| explain | ||
| ----------------------------------------------------------------------------------------------- | ||
| Bitmap Heap Scan on spoint10k (rows=2298 width=16) (actual rows=3009 loops=1) | ||
| Filter: spoint_dwithin(star, '(1 , 1)'::spoint, '1'::double precision) | ||
| Rows Removed by Filter: 1560 | ||
| Heap Blocks: exact=55 | ||
| -> Bitmap Index Scan on spoint10k_star_idx (rows=2298 width=0) (actual rows=4569 loops=1) | ||
| Index Cond: (star <@ '<(1 , 1) , 1>'::scircle) | ||
| (6 rows) | ||
|  | ||
| select explain('select * from spoint10k where spoint_dwithin(star, spoint(1,1), .1)'); | ||
| explain | ||
| ------------------------------------------------------------------------------------------- | ||
| Bitmap Heap Scan on spoint10k (rows=25 width=16) (actual rows=29 loops=1) | ||
| Filter: spoint_dwithin(star, '(1 , 1)'::spoint, '0.1'::double precision) | ||
| Rows Removed by Filter: 19 | ||
| Heap Blocks: exact=32 | ||
| -> Bitmap Index Scan on spoint10k_star_idx (rows=25 width=0) (actual rows=48 loops=1) | ||
| Index Cond: (star <@ '<(1 , 1) , 0.1>'::scircle) | ||
| (6 rows) | ||
|  | ||
| select explain('select * from spoint10k where spoint_dwithin(star, spoint(1,1), .01)'); | ||
| explain | ||
| --------------------------------------------------------------------------------------------- | ||
| Index Scan using spoint10k_star_idx on spoint10k (rows=1 width=16) (actual rows=1 loops=1) | ||
| Index Cond: (star <@ '<(1 , 1) , 0.01>'::scircle) | ||
| (2 rows) | ||
|  | ||
| select explain('select * from spoint10k where spoint_dwithin(spoint(1,1), star, 1)'); | ||
| explain | ||
| ----------------------------------------------------------------------------------------------- | ||
| Bitmap Heap Scan on spoint10k (rows=2298 width=16) (actual rows=3009 loops=1) | ||
| Filter: spoint_dwithin('(1 , 1)'::spoint, star, '1'::double precision) | ||
| Rows Removed by Filter: 1560 | ||
| Heap Blocks: exact=55 | ||
| -> Bitmap Index Scan on spoint10k_star_idx (rows=2298 width=0) (actual rows=4569 loops=1) | ||
| Index Cond: (star <@ '<(1 , 1) , 1>'::scircle) | ||
| (6 rows) | ||
|  | ||
| select explain('select * from spoint10k where spoint_dwithin(spoint(1,1), star, .1)'); | ||
| explain | ||
| ------------------------------------------------------------------------------------------- | ||
| Bitmap Heap Scan on spoint10k (rows=25 width=16) (actual rows=29 loops=1) | ||
| Filter: spoint_dwithin('(1 , 1)'::spoint, star, '0.1'::double precision) | ||
| Rows Removed by Filter: 19 | ||
| Heap Blocks: exact=32 | ||
| -> Bitmap Index Scan on spoint10k_star_idx (rows=25 width=0) (actual rows=48 loops=1) | ||
| Index Cond: (star <@ '<(1 , 1) , 0.1>'::scircle) | ||
| (6 rows) | ||
|  | ||
| select explain('select * from spoint10k where spoint_dwithin(spoint(1,1), star, .01)'); | ||
| explain | ||
| --------------------------------------------------------------------------------------------- | ||
| Index Scan using spoint10k_star_idx on spoint10k (rows=1 width=16) (actual rows=1 loops=1) | ||
| Index Cond: (star <@ '<(1 , 1) , 0.01>'::scircle) | ||
| (2 rows) | ||
|  | ||
| select explain('select * from spoint10k a join spoint10k b on spoint_dwithin(a.star, b.star, 1)', do_analyze := 'false'); | ||
| explain | ||
| --------------------------------------------------------------------------------------- | ||
| Nested Loop (rows=22984885 width=32) | ||
| -> Seq Scan on spoint10k a (rows=10000 width=16) | ||
| -> Index Scan using spoint10k_star_idx on spoint10k b (rows=2298 width=16) | ||
| Index Cond: (star OPERATOR(public.<@) scircle(a.star, '1'::double precision)) | ||
| (4 rows) | ||
|  | ||
| select explain('select * from spoint10k a join spoint10k b on spoint_dwithin(a.star, b.star, .1)'); | ||
| explain | ||
| ----------------------------------------------------------------------------------------------------------- | ||
| Nested Loop (rows=249792 width=32) (actual rows=505342 loops=1) | ||
| -> Seq Scan on spoint10k a (rows=10000 width=16) (actual rows=10000 loops=1) | ||
| -> Index Scan using spoint10k_star_idx on spoint10k b (rows=25 width=16) (actual rows=51 loops=10000) | ||
| Index Cond: (star OPERATOR(public.<@) scircle(a.star, '0.1'::double precision)) | ||
| Rows Removed by Index Recheck: 31 | ||
| (5 rows) | ||
|  | ||
| select explain('select * from spoint10k a join spoint10k b on spoint_dwithin(a.star, b.star, .01)'); | ||
| explain | ||
| --------------------------------------------------------------------------------------------------------- | ||
| Nested Loop (rows=2500 width=32) (actual rows=17614 loops=1) | ||
| -> Seq Scan on spoint10k a (rows=10000 width=16) (actual rows=10000 loops=1) | ||
| -> Index Scan using spoint10k_star_idx on spoint10k b (rows=1 width=16) (actual rows=2 loops=10000) | ||
| Index Cond: (star OPERATOR(public.<@) scircle(a.star, '0.01'::double precision)) | ||
| Rows Removed by Index Recheck: 1 | ||
| (5 rows) | ||
|  | ||
| -- spoint_dwithin is symmetric in the first two arguments | ||
| select explain('select * from spoint10k a join spoint10k b on spoint_dwithin(a.star, b.star, .01) | ||
| where spoint_dwithin(a.star, spoint(1,1), .1)'); | ||
| explain | ||
| ------------------------------------------------------------------------------------------------------ | ||
| Nested Loop (rows=6 width=32) (actual rows=33 loops=1) | ||
| -> Bitmap Heap Scan on spoint10k a (rows=25 width=16) (actual rows=29 loops=1) | ||
| Filter: spoint_dwithin(star, '(1 , 1)'::spoint, '0.1'::double precision) | ||
| Rows Removed by Filter: 19 | ||
| Heap Blocks: exact=32 | ||
| -> Bitmap Index Scan on spoint10k_star_idx (rows=25 width=0) (actual rows=48 loops=1) | ||
| Index Cond: (star <@ '<(1 , 1) , 0.1>'::scircle) | ||
| -> Index Scan using spoint10k_star_idx on spoint10k b (rows=1 width=16) (actual rows=1 loops=29) | ||
| Index Cond: (star OPERATOR(public.<@) scircle(a.star, '0.01'::double precision)) | ||
| Rows Removed by Index Recheck: 0 | ||
| (10 rows) | ||
|  | ||
| select explain('select * from spoint10k a join spoint10k b on spoint_dwithin(b.star, a.star, .01) | ||
| where spoint_dwithin(a.star, spoint(1,1), .1)'); | ||
| explain | ||
| ------------------------------------------------------------------------------------------------------ | ||
| Nested Loop (rows=6 width=32) (actual rows=33 loops=1) | ||
| -> Bitmap Heap Scan on spoint10k a (rows=25 width=16) (actual rows=29 loops=1) | ||
| Filter: spoint_dwithin(star, '(1 , 1)'::spoint, '0.1'::double precision) | ||
| Rows Removed by Filter: 19 | ||
| Heap Blocks: exact=32 | ||
| -> Bitmap Index Scan on spoint10k_star_idx (rows=25 width=0) (actual rows=48 loops=1) | ||
| Index Cond: (star <@ '<(1 , 1) , 0.1>'::scircle) | ||
| -> Index Scan using spoint10k_star_idx on spoint10k b (rows=1 width=16) (actual rows=1 loops=29) | ||
| Index Cond: (star OPERATOR(public.<@) scircle(a.star, '0.01'::double precision)) | ||
| Rows Removed by Index Recheck: 0 | ||
| (10 rows) | ||
|  | ||
| -- both sides indexable, check if the planner figures out the better choice | ||
| select explain('select * from spoint10k a join spoint10k b on spoint_dwithin(a.star, b.star, .01) | ||
| where spoint_dwithin(a.star, spoint(1,1), .1) and spoint_dwithin(b.star, spoint(1,1), .05)'); | ||
| explain | ||
| ------------------------------------------------------------------------------------------------------------------------------------- | ||
| Nested Loop (rows=1 width=32) (actual rows=16 loops=1) | ||
| -> Bitmap Heap Scan on spoint10k b (rows=6 width=16) (actual rows=12 loops=1) | ||
| Filter: spoint_dwithin(star, '(1 , 1)'::spoint, '0.05'::double precision) | ||
| Rows Removed by Filter: 4 | ||
| Heap Blocks: exact=14 | ||
| -> Bitmap Index Scan on spoint10k_star_idx (rows=6 width=0) (actual rows=16 loops=1) | ||
| Index Cond: (star <@ '<(1 , 1) , 0.05>'::scircle) | ||
| -> Index Scan using spoint10k_star_idx on spoint10k a (rows=1 width=16) (actual rows=1 loops=12) | ||
| Index Cond: ((star OPERATOR(public.<@) scircle(b.star, '0.01'::double precision)) AND (star <@ '<(1 , 1) , 0.1>'::scircle)) | ||
| Rows Removed by Index Recheck: 0 | ||
| (10 rows) | ||
|  | ||
| select explain('select * from spoint10k a join spoint10k b on spoint_dwithin(a.star, b.star, .01) | ||
| where spoint_dwithin(a.star, spoint(1,1), .05) and spoint_dwithin(b.star, spoint(1,1), .1)'); | ||
| explain | ||
| ------------------------------------------------------------------------------------------------------------------------------------- | ||
| Nested Loop (rows=1 width=32) (actual rows=16 loops=1) | ||
| -> Bitmap Heap Scan on spoint10k a (rows=6 width=16) (actual rows=12 loops=1) | ||
| Filter: spoint_dwithin(star, '(1 , 1)'::spoint, '0.05'::double precision) | ||
| Rows Removed by Filter: 4 | ||
| Heap Blocks: exact=14 | ||
| -> Bitmap Index Scan on spoint10k_star_idx (rows=6 width=0) (actual rows=16 loops=1) | ||
| Index Cond: (star <@ '<(1 , 1) , 0.05>'::scircle) | ||
| -> Index Scan using spoint10k_star_idx on spoint10k b (rows=1 width=16) (actual rows=1 loops=12) | ||
| Index Cond: ((star OPERATOR(public.<@) scircle(a.star, '0.01'::double precision)) AND (star <@ '<(1 , 1) , 0.1>'::scircle)) | ||
| Rows Removed by Index Recheck: 0 | ||
| (10 rows) | ||
|  | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.