Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm skeptical that this has anything to do with bad statistics unless you consider the combination of database statistics and your custom data type. </p> <p>My guess is that PostgreSQL is picking a <em>nested loop</em> join because it looks at the predicates <code>(treenode.location).x &gt;= 8000 AND (treenode.location).x &lt;= (8000 + 4736)</code> and does something funky in the arithmetic of your comparison. A <em>nested loop</em> is typically going to be used when you have a small amount of data in the inner side of the join.</p> <p>But, once you switch the constant to 10736 you get a different plan. It's always possible that the plan is of sufficiently complexity that the <em>Genetic Query Optimization (GEQO)</em> is kicking in and you're seeing the side effects of <em>non-deterministic plan building</em>. There are enough discrepancies in the order of evaluation in the queries to make me think that's what's going on. </p> <p>One option would be to examine using a parameterized/prepared statement for this instead of using ad hoc code. Since you're working in a 3-dimensional space, you might also want to considering using <a href="http://postgis.refractions.net/documentation/manual-1.5/ch08.html#PostGIS_3D_Functions" rel="nofollow">PostGIS</a>. While it might be overkill, it may also be able to provide you with the performance that you need to get these queries running properly.</p> <p>While forcing planner behavior isn't the best choice, sometimes we do end up making better decisions than the software.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload