Skip to content

Commit

Permalink
disable sequential scanning for carton program query to speed irt up (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
imedan authored Mar 8, 2024
1 parent 29adc95 commit 41ae433
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions python/valis/routes/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
carton_program_list, carton_program_map,
get_targets_by_sdss_id, get_targets_by_catalog_id,
get_targets_obs)
from sdssdb.peewee.sdss5db import database

# convert string floats to proper floats
Float = Annotated[Union[float, str], BeforeValidator(lambda x: float(x) if x and isinstance(x, str) else x)]
Expand Down Expand Up @@ -159,8 +160,9 @@ async def carton_program(self,
description='Specify search on carton or program',
example='carton')] = 'carton'):
""" Perform a search on carton or program """

return list(carton_program_search(name, name_type))
with database.atomic() as transaction:
database.execute_sql('SET LOCAL enable_seqscan=false;')
return list(carton_program_search(name, name_type))

@router.get('/obs', summary='Return targets with spectrum at observatory',
response_model=List[SDSSidStackedBase], dependencies=[Depends(get_pw_db)])
Expand Down

0 comments on commit 41ae433

Please sign in to comment.