datajoint-python icon indicating copy to clipboard operation
datajoint-python copied to clipboard

unnecessary SQL subquery

Open dimitri-yatsenko opened this issue 8 years ago • 1 comments
trafficstars

When displaying a table in Jupyter, the underlying query contains an extra query that significantly slows down the performance.

For example, previewing the table

edgy.Mesh.Fragment() & 'boss_vset_id=27754605'

produces the following query

SELECT * FROM (
    SELECT `boss_vset_id`,`fragment`,`bound_x_min`,`bound_x_max`,`bound_y_min`,`bound_y_max`,`bound_z_min`,`bound_z_max`,`n_vertices`,`n_triangles`,'=BLOB=' as `vertices`,'=BLOB=' as `triangles` 
        FROM `microns_em`.`_mesh__fragment`) as `_s4` 
    WHERE (boss_vset_id=27754605) LIMIT 8

The extra SELECT * FROM( ... ) is unnecessary and, unfortunately, MySQL cannot optimize it. With tens of millions of tuples, this query takes minutes instead of milliseconds.

dimitri-yatsenko avatar Aug 06 '17 16:08 dimitri-yatsenko

Possibly addressed in PR #754. @ixcat to confirm.

guzman-raphael avatar Jan 25 '21 17:01 guzman-raphael