Thanks for this Suber.
I know this is not obvious (and not ideal) but: when spatial constraints are included in an ADQL query as max/min values on the RA and Dec columns, the processing time might not go down. I think the system interprets the request in the same way as other column constraints, and reviews all table rows.
I see now that in under “General Advice” on the DP0.2 ADQL Queries page, it just says “It is recommended to use either an ADQL Cone Search or a Polygon Search, and to not use a WHERE … BETWEEN statement to set boundaries on RA and Dec.” I’ll make an edit there to better explain it’s not just recommended, but necessary for efficient queries.
The other factor affecting your results here is that the DP0.2 area only includes RA of about 50 to 75 deg, and Dec of about -27 to -45 deg. I think that’s why a few of your cycles returned no results, they were just out of bounds. The best figure for a quick reference of the DP0.2 area is Figure 15 from The LSST DESC DC2 Simulated Sky Survey, which I’ll paste below but is also on the DP0.2 Data Products Definitions page.
Below I put together a sample query that I think is similar to what you’re after. It uses the POLYGON
constraint to define a 5x5 deg region of sky, applies your other column constraints, and returns the COUNT
.
from lsst.rsp import get_tap_service, retrieve_query
service = get_tap_service("tap")
query = "SELECT COUNT(coord_ra) "\
"FROM dp02_dc2_catalogs.Object "\
"WHERE CONTAINS(POINT('ICRS', coord_ra, coord_dec), "\
"POLYGON('ICRS', 65.0, -35.0, 65.0, -40.0, 70.0, -40.0, 70.0, -35.0))=1 "\
"AND scisql_nanojanskyToAbMag(g_psfFlux) > 17 "\
"AND scisql_nanojanskyToAbMag(g_psfFlux) < 21 "\
"AND g_extendedness = 0.0 "\
"AND r_extendedness = 0.0 "\
"AND i_extendedness = 0.0 "\
"AND detect_isPrimary = 1 "
print(query)
job = service.submit_job(query)
job.run()
job.wait(phases=['COMPLETED', 'ERROR'])
print('Job phase is', job.phase)
results = job.fetch_result().to_table()
results
The above took about 1.5 minutes to run and returned a count of 29592.
I think that the above is going to set you up for more success, so I’m going to mark this reply post as the “solution” for this topic thread, but: as always, please do start up a new topic with any future questions or issues!