Skip to content

Commit

Permalink
Only vacuum output tables if we actually loaded something
Browse files Browse the repository at this point in the history
  • Loading branch information
albireox committed Apr 25, 2024
1 parent 9a974e8 commit 4dfc52f
Show file tree
Hide file tree
Showing 2 changed files with 124 additions and 2 deletions.
119 changes: 119 additions & 0 deletions .nfs38073c0984a6d27c00000720
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
2024-04-25 11:52:47,104 - INFO - plan = '1.1.1'; run_id = 9; tag = '1.2.1a0'.
2024-04-25 11:52:47,105 - INFO - Reference Epoch = 2016.0
2024-04-25 11:52:47,932 - INFO - Query radius = 1.0
2024-04-25 11:52:47,933 - DEBUG - Current database configuration parameters.
2024-04-25 11:52:47,933 - DEBUG - shared_buffers = 76GB
2024-04-25 11:52:47,934 - DEBUG - effective_cache_size = 176GB
2024-04-25 11:52:47,934 - DEBUG - wal_buffers = 16MB
2024-04-25 11:52:47,935 - DEBUG - effective_io_concurrency = 200
2024-04-25 11:52:47,937 - DEBUG - work_mem = 5GB
2024-04-25 11:52:47,938 - DEBUG - max_worker_processes = 32
2024-04-25 11:52:47,939 - DEBUG - random_page_cost = 1
2024-04-25 11:52:47,941 - DEBUG - seq_page_cost = 0.5
2024-04-25 11:52:47,943 - DEBUG - cpu_index_tuple_cost = 0.005
2024-04-25 11:52:47,944 - DEBUG - cpu_operator_cost = 0.0025
2024-04-25 11:52:47,945 - DEBUG - default_statistics_target = 3000
2024-04-25 11:52:47,947 - DEBUG - temp_buffers = 10GB
2024-04-25 11:52:47,948 - DEBUG - plan_cache_mode = auto
2024-04-25 11:52:47,949 - DEBUG - geqo_effort = 5
2024-04-25 11:52:47,950 - DEBUG - force_parallel_mode = off
2024-04-25 11:52:47,952 - DEBUG - enable_seqscan = on
2024-04-25 11:52:47,953 - DEBUG - enable_nestloop = on
2024-04-25 11:52:47,958 - INFO - processing order: ['marvels_dr11_star']
2024-04-25 11:54:27,448 - INFO - Using version record (31, 1.1.1, 1.2.1a0).
2024-04-25 11:54:27,465 - WARNING - 'catalog' contains records for this cross-matching plan (1.1.1).
2024-04-25 11:54:27,475 - INFO - Created table catalog_872ccd9c6dce18ce.
2024-04-25 11:54:27,475 - INFO - [MARVELS_DR11_STAR] Processing table marvels_dr11_star.
2024-04-25 11:54:27,475 - DEBUG - [MARVELS_DR11_STAR] Table cross-matching parameters:
2024-04-25 11:54:27,476 - DEBUG - [MARVELS_DR11_STAR] ra_column: ra_final
2024-04-25 11:54:27,478 - DEBUG - [MARVELS_DR11_STAR] dec_column: dec_final
2024-04-25 11:54:27,479 - DEBUG - [MARVELS_DR11_STAR] pmra_column: none
2024-04-25 11:54:27,480 - DEBUG - [MARVELS_DR11_STAR] pmdec_column: none
2024-04-25 11:54:27,481 - DEBUG - [MARVELS_DR11_STAR] is_pmra_cos: true
2024-04-25 11:54:27,482 - DEBUG - [MARVELS_DR11_STAR] parallax_column: none
2024-04-25 11:54:27,484 - DEBUG - [MARVELS_DR11_STAR] epoch: none
2024-04-25 11:54:27,485 - DEBUG - [MARVELS_DR11_STAR] epoch_column: none
2024-04-25 11:54:27,487 - DEBUG - [MARVELS_DR11_STAR] epoch_format: jyear
2024-04-25 11:54:27,489 - DEBUG - [MARVELS_DR11_STAR] has_duplicates: false
2024-04-25 11:54:27,490 - DEBUG - [MARVELS_DR11_STAR] skip: false
2024-04-25 11:54:27,492 - DEBUG - [MARVELS_DR11_STAR] skip_phases: []
2024-04-25 11:54:27,493 - DEBUG - [MARVELS_DR11_STAR] query_radius: 1.0
2024-04-25 11:54:27,494 - DEBUG - [MARVELS_DR11_STAR] row_count: 7,066
2024-04-25 11:54:27,496 - DEBUG - [MARVELS_DR11_STAR] resolution: nan
2024-04-25 11:54:27,497 - DEBUG - [MARVELS_DR11_STAR] join_weight: 1
2024-04-25 11:54:27,499 - DEBUG - [MARVELS_DR11_STAR] has_missing_coordinates: false
2024-04-25 11:54:27,519 - INFO - [MARVELS_DR11_STAR] Phase 1: linking existing targets.
2024-04-25 11:54:27,521 - DEBUG - [MARVELS_DR11_STAR] Found 2 paths between marvels_dr11_star and temporary output table.
2024-04-25 11:54:27,528 - DEBUG - [MARVELS_DR11_STAR] SET LOCAL work_mem='10GB';
2024-04-25 11:54:27,528 - DEBUG - [MARVELS_DR11_STAR] SET LOCAL temp_buffers='5GB';
2024-04-25 11:54:27,529 - DEBUG - [MARVELS_DR11_STAR] SET LOCAL enable_hashjoin=False;
2024-04-25 11:54:27,531 - DEBUG - [MARVELS_DR11_STAR] Selecting linked targets into temporary table 'ce8a3e47' with join path ['marvels_dr11_star', 'tycho2', 'catalog_to_tycho2']: SELECT DISTINCT ON ("t1"."starname") "t1"."starname" AS "target_id", "t2"."catalogid", True AS "best" FROM "catalogdb"."marvels_dr11_star" AS "t1" INNER JOIN "catalogdb"."tycho2" AS "t3" ON ("t1"."tycho2_designation" = "t3"."designation") INNER JOIN "catalogdb"."catalog_to_tycho2" AS "t2" ON ("t2"."target_id" = "t3"."designation") WHERE ((("t2"."version_id" = 31) AND ("t2"."best" IS True)) AND NOT EXISTS(SELECT 1 FROM "sandbox"."catalog_to_marvels_dr11_star_872ccd9c6dce18ce" AS "t4" WHERE (("t4"."version_id" = 31) AND (("t4"."target_id" = "t1"."starname") OR ("t4"."catalogid" = "t2"."catalogid")))))
2024-04-25 11:54:27,661 - DEBUG - [MARVELS_DR11_STAR] Copying data into relational model 'catalog_to_marvels_dr11_star_872ccd9c6dce18ce'.
2024-04-25 11:54:27,713 - DEBUG - [MARVELS_DR11_STAR] Linked 6,636 records in 0.186 s.
2024-04-25 11:54:27,713 - DEBUG - [MARVELS_DR11_STAR] Running ANALYZE on catalog_to_marvels_dr11_star_872ccd9c6dce18ce.
2024-04-25 11:54:27,732 - DEBUG - [MARVELS_DR11_STAR] SET LOCAL work_mem='10GB';
2024-04-25 11:54:27,732 - DEBUG - [MARVELS_DR11_STAR] SET LOCAL temp_buffers='5GB';
2024-04-25 11:54:27,732 - DEBUG - [MARVELS_DR11_STAR] SET LOCAL enable_hashjoin=False;
2024-04-25 11:54:27,734 - DEBUG - [MARVELS_DR11_STAR] Selecting linked targets into temporary table '15ee86c1' with join path ['marvels_dr11_star', 'twomass_psc', 'catalog_to_twomass_psc']: SELECT DISTINCT ON ("t1"."starname") "t1"."starname" AS "target_id", "t2"."catalogid", True AS "best" FROM "catalogdb"."marvels_dr11_star" AS "t1" INNER JOIN "catalogdb"."twomass_psc" AS "t3" ON ("t1"."twomass_designation" = "t3"."designation") INNER JOIN "catalogdb"."catalog_to_twomass_psc" AS "t2" ON ("t2"."target_id" = "t3"."pts_key") WHERE ((("t2"."version_id" = 31) AND ("t2"."best" IS True)) AND NOT EXISTS(SELECT 1 FROM "sandbox"."catalog_to_marvels_dr11_star_872ccd9c6dce18ce" AS "t4" WHERE (("t4"."version_id" = 31) AND (("t4"."target_id" = "t1"."starname") OR ("t4"."catalogid" = "t2"."catalogid")))))
2024-04-25 11:54:27,945 - DEBUG - [MARVELS_DR11_STAR] Copying data into relational model 'catalog_to_marvels_dr11_star_872ccd9c6dce18ce'.
2024-04-25 11:54:27,950 - DEBUG - [MARVELS_DR11_STAR] Linked 430 records in 0.219 s.
2024-04-25 11:54:27,950 - DEBUG - [MARVELS_DR11_STAR] Running ANALYZE on catalog_to_marvels_dr11_star_872ccd9c6dce18ce.
2024-04-25 11:54:27,997 - INFO - [MARVELS_DR11_STAR] Phase 2: cross-matching against existing targets (catalog_872ccd9c6dce18ce).
2024-04-25 11:54:28,011 - DEBUG - [MARVELS_DR11_STAR] SET LOCAL work_mem='10GB';
2024-04-25 11:54:28,011 - DEBUG - [MARVELS_DR11_STAR] SET LOCAL temp_buffers='5GB';
2024-04-25 11:54:28,013 - DEBUG - [MARVELS_DR11_STAR] SET LOCAL enable_hashjoin=False;
2024-04-25 11:54:28,016 - DEBUG - [MARVELS_DR11_STAR] Running Q3C query and inserting cross-matched data into relational table 'catalog_to_marvels_dr11_star_872ccd9c6dce18ce': : INSERT INTO "sandbox"."catalog_to_marvels_dr11_star_872ccd9c6dce18ce" ("target_id", "catalogid", "version_id", "distance", "best", "plan_id", "added_by_phase") WITH "xmatched" AS MATERIALIZED (SELECT "t1"."catalogid", "t2"."starname" AS "target_id", q3c_dist("t2"."ra_final", "t2"."dec_final", "t1"."ra", "t1"."dec") AS "distance", "t1"."version_id" FROM "sandbox"."catalog_872ccd9c6dce18ce" AS "t1" CROSS JOIN "catalogdb"."marvels_dr11_star" AS "t2" WHERE (q3c_join("t2"."ra_final", "t2"."dec_final", "t1"."ra", "t1"."dec", 0.0002777777777777778) AND True)) SELECT "xmatched"."target_id", "xmatched"."catalogid", 31 AS "version_id", "xmatched"."distance" AS "distance", (first_value("xmatched"."target_id") OVER (PARTITION BY "xmatched"."catalogid" ORDER BY "xmatched"."distance" ASC) = "xmatched"."target_id") AS "best", '1.1.1', 2 AS "added_by_phase" FROM "xmatched" WHERE (("xmatched"."version_id" = 31) AND NOT EXISTS(SELECT 1 FROM "sandbox"."catalog_to_marvels_dr11_star_872ccd9c6dce18ce" AS "catalog_to_marvels_dr11_star_872ccd9c6dce18ce" WHERE (("catalog_to_marvels_dr11_star_872ccd9c6dce18ce"."version_id" = 31) AND (("catalog_to_marvels_dr11_star_872ccd9c6dce18ce"."catalogid" = "xmatched"."catalogid") OR ("catalog_to_marvels_dr11_star_872ccd9c6dce18ce"."target_id" = "xmatched"."target_id")))))
2024-04-25 11:54:28,347 - DEBUG - [MARVELS_DR11_STAR] Cross-matched catalog_872ccd9c6dce18ce with 0 targets in marvels_dr11_star. Run in 0.336 s.
2024-04-25 11:54:28,347 - INFO - [MARVELS_DR11_STAR] Phase 2: cross-matching against existing targets (catalog).
2024-04-25 11:54:28,361 - DEBUG - [MARVELS_DR11_STAR] SET LOCAL work_mem='10GB';
2024-04-25 11:54:28,361 - DEBUG - [MARVELS_DR11_STAR] SET LOCAL temp_buffers='5GB';
2024-04-25 11:54:28,363 - DEBUG - [MARVELS_DR11_STAR] SET LOCAL enable_hashjoin=False;
2024-04-25 11:54:28,366 - DEBUG - [MARVELS_DR11_STAR] Running Q3C query and inserting cross-matched data into relational table 'catalog_to_marvels_dr11_star_872ccd9c6dce18ce': : INSERT INTO "sandbox"."catalog_to_marvels_dr11_star_872ccd9c6dce18ce" ("target_id", "catalogid", "version_id", "distance", "best", "plan_id", "added_by_phase") WITH "xmatched" AS MATERIALIZED (SELECT "t1"."catalogid", "t2"."starname" AS "target_id", q3c_dist("t2"."ra_final", "t2"."dec_final", "t1"."ra", "t1"."dec") AS "distance", "t1"."version_id" FROM "catalogdb"."catalog" AS "t1" CROSS JOIN "catalogdb"."marvels_dr11_star" AS "t2" WHERE (q3c_join("t2"."ra_final", "t2"."dec_final", "t1"."ra", "t1"."dec", 0.0002777777777777778) AND True)) SELECT "xmatched"."target_id", "xmatched"."catalogid", 31 AS "version_id", "xmatched"."distance" AS "distance", (first_value("xmatched"."target_id") OVER (PARTITION BY "xmatched"."catalogid" ORDER BY "xmatched"."distance" ASC) = "xmatched"."target_id") AS "best", '1.1.1', 2 AS "added_by_phase" FROM "xmatched" WHERE (("xmatched"."version_id" = 31) AND NOT EXISTS(SELECT 1 FROM "sandbox"."catalog_to_marvels_dr11_star_872ccd9c6dce18ce" AS "catalog_to_marvels_dr11_star_872ccd9c6dce18ce" WHERE (("catalog_to_marvels_dr11_star_872ccd9c6dce18ce"."version_id" = 31) AND (("catalog_to_marvels_dr11_star_872ccd9c6dce18ce"."catalogid" = "xmatched"."catalogid") OR ("catalog_to_marvels_dr11_star_872ccd9c6dce18ce"."target_id" = "xmatched"."target_id")))))
2024-04-25 11:54:28,877 - DEBUG - [MARVELS_DR11_STAR] Cross-matched catalog with 0 targets in marvels_dr11_star. Run in 0.515 s.
2024-04-25 11:54:28,877 - INFO - [MARVELS_DR11_STAR] Phase 3: adding non cross-matched targets.
2024-04-25 11:54:28,892 - DEBUG - [MARVELS_DR11_STAR] SET LOCAL work_mem='10GB';
2024-04-25 11:54:28,892 - DEBUG - [MARVELS_DR11_STAR] SET LOCAL temp_buffers='5GB';
2024-04-25 11:54:28,894 - DEBUG - [MARVELS_DR11_STAR] SET LOCAL enable_hashjoin=False;
2024-04-25 11:54:28,897 - DEBUG - [MARVELS_DR11_STAR] Selecting unique targets into temporary table 'dcddcfc2': SELECT (row_number() OVER () + 81064793292668928) AS "catalogid", "t1"."starname" AS "target_id", "t1"."ra_final" AS "ra", "t1"."dec_final" AS "dec" FROM "catalogdb"."marvels_dr11_star" AS "t1" WHERE (True AND NOT EXISTS(SELECT 1 FROM "sandbox"."catalog_to_marvels_dr11_star_872ccd9c6dce18ce" AS "t2" WHERE ((("t2"."version_id" = 31) AND ("t2"."target_id" = "t1"."starname")) AND ("t2"."best" IS True))))
2024-04-25 11:54:28,909 - DEBUG - [MARVELS_DR11_STAR] Copying data into relational model 'catalog_to_marvels_dr11_star_872ccd9c6dce18ce': INSERT INTO "sandbox"."catalog_to_marvels_dr11_star_872ccd9c6dce18ce" ("catalogid", "target_id", "version_id", "best", "plan_id", "added_by_phase") SELECT "t1"."catalogid", "t1"."target_id", 31, true, '1.1.1', 3 AS "added_by_phase" FROM "dcddcfc2" AS "t1"
2024-04-25 11:54:28,910 - DEBUG - [MARVELS_DR11_STAR] Insertion into catalog_to_marvels_dr11_star_872ccd9c6dce18ce completed with 0 rows in 0.018 s.
2024-04-25 11:54:28,911 - DEBUG - [MARVELS_DR11_STAR] Running INSERT query into catalog_872ccd9c6dce18ce: INSERT INTO "sandbox"."catalog_872ccd9c6dce18ce" ("catalogid", "lead", "version_id", "ra", "dec") SELECT "t1"."catalogid", 'marvels_dr11_star', 31, "t1"."ra", "t1"."dec" FROM "dcddcfc2" AS "t1"
2024-04-25 11:54:28,912 - DEBUG - [MARVELS_DR11_STAR] Inserted 0 rows. Total time: 0.020 s.
2024-04-25 11:54:28,913 - DEBUG - [MARVELS_DR11_STAR] Running ANALYZE on catalog_to_marvels_dr11_star_872ccd9c6dce18ce.
2024-04-25 11:54:28,960 - INFO - [MARVELS_DR11_STAR] Fully processed marvels_dr11_star in 1 s.
2024-04-25 11:54:28,963 - INFO - Cross-matching completed in 1.488 s.
2024-04-25 15:39:42,111 - INFO - plan = '1.1.1'; run_id = 9; tag = '1.2.1a0'.
2024-04-25 15:39:42,112 - INFO - Reference Epoch = 2016.0
2024-04-25 15:39:42,934 - INFO - Query radius = 1.0
2024-04-25 15:39:42,935 - DEBUG - Current database configuration parameters.
2024-04-25 15:39:42,936 - DEBUG - shared_buffers = 76GB
2024-04-25 15:39:42,937 - DEBUG - effective_cache_size = 176GB
2024-04-25 15:39:42,938 - DEBUG - wal_buffers = 16MB
2024-04-25 15:39:42,940 - DEBUG - effective_io_concurrency = 200
2024-04-25 15:39:42,941 - DEBUG - work_mem = 5GB
2024-04-25 15:39:42,942 - DEBUG - max_worker_processes = 32
2024-04-25 15:39:42,943 - DEBUG - random_page_cost = 1
2024-04-25 15:39:42,944 - DEBUG - seq_page_cost = 0.5
2024-04-25 15:39:42,945 - DEBUG - cpu_index_tuple_cost = 0.005
2024-04-25 15:39:42,946 - DEBUG - cpu_operator_cost = 0.0025
2024-04-25 15:39:42,947 - DEBUG - default_statistics_target = 3000
2024-04-25 15:39:42,948 - DEBUG - temp_buffers = 10GB
2024-04-25 15:39:42,949 - DEBUG - plan_cache_mode = auto
2024-04-25 15:39:42,950 - DEBUG - geqo_effort = 5
2024-04-25 15:39:42,951 - DEBUG - force_parallel_mode = off
2024-04-25 15:39:42,952 - DEBUG - enable_seqscan = on
2024-04-25 15:39:42,953 - DEBUG - enable_nestloop = on
2024-04-25 15:39:42,958 - INFO - processing order: ['marvels_dr11_star']
2024-04-25 15:40:00,517 - INFO - Using version record (31, 1.1.1, 1.2.1a0).
2024-04-25 15:40:00,535 - WARNING - 'catalog' contains records for this cross-matching plan (1.1.1).
2024-04-25 15:40:00,997 - ERROR - Traceback (most recent call last):
File "/uufs/chpc.utah.edu/common/home/u0931042/.pyenv/versions/3.12.3/envs/target_selection/lib/python3.12/site-packages/IPython/core/interactiveshell.py", line 3577, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-5-2f10892a3467>", line 1, in <module>
xm.run()
File "/uufs/chpc.utah.edu/common/home/u0931042/software/target_selection/python/target_selection/xmatch.py", line 1138, in run
self._create_models(force or (from_ is not None))
File "/uufs/chpc.utah.edu/common/home/u0931042/software/target_selection/python/target_selection/xmatch.py", line 1054, in _create_models
raise XMatchError(msg)
target_selection.exceptions.XMatchError: Temporary table catalog_872ccd9c6dce18ce already exists.

7 changes: 5 additions & 2 deletions python/target_selection/xmatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,8 @@ def __init__(self, database, models, plan, run_id, version_id=None,
sample_region=None, database_options=None, path_mode='full',
join_paths=None):

from sdssdb.peewee.sdss5db import catalogdb # noqa

self.log = log or target_selection.log
self.log.header = ''

Expand Down Expand Up @@ -1917,8 +1919,9 @@ def _load_output_table(self, from_model, to_model, keep_temp=False):
self.database.drop_tables([from_model])
self.log.info(f'Dropped temporary table {from_table}.')

self.log.debug(f'Running VACUUM ANALYZE on {to_table}.')
vacuum_table(self.database, to_table, vacuum=True, analyze=True)
if n_rows > 0:
self.log.debug(f'Running VACUUM ANALYZE on {to_table}.')
vacuum_table(self.database, to_table, vacuum=True, analyze=True)

def _get_sql(self, query, return_string=False):
"""Returns colourised SQL text for logging."""
Expand Down

0 comments on commit 4dfc52f

Please sign in to comment.