4.1. Example Queries

4.1.2. Cross Match

Cross matching is a resource-intensive operation, so expect it to run quite long. However, you can get really good performance if you have one table significantly small in number of rows.

Here we have the Dark Energy Survey Science Verification first Annual survey cross-matching against the GAIA DR1 survey within .001 degrees.

Note here we do not use the JOIN clause in SQL which is one reason it is a resource-intensive query. This is the time you want a Cartesian join due to the nature of cross-matching. The other thing to notice is the smaller table by number of rows is listed first in the q3c_join() clause (i.e. d.ra_j200 and d.dec_j2000).

SELECT count(*)
  FROM des_sva1.gold_catalog AS d,
       gaia_dr1.gaia_source AS g
 WHERE q3c_join(d.ra_j2000, d.dec_j2000, g.ra, g.dec, .001);

Returns 1,307,402 rows in 179 sec.