From 8c2fff0b3efa458d5fe9054a045131c8fa08bff0 Mon Sep 17 00:00:00 2001 From: FHU-yezi Date: Fri, 1 Nov 2024 21:02:43 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BD=BF=E7=94=A8=E5=88=86=E5=8C=BA?= =?UTF-8?q?=E8=A1=A8=E4=BC=98=E5=8C=96=E7=AE=80=E4=B9=A6=E7=A7=AF=E5=88=86?= =?UTF-8?q?=E5=85=91=E6=8D=A2=E5=B9=B3=E5=8F=B0=E5=B8=82=E5=9C=BA=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E8=A1=A8=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/jpep/new/ftn_macket_record.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/models/jpep/new/ftn_macket_record.py b/models/jpep/new/ftn_macket_record.py index 4400b2b..b59117f 100644 --- a/models/jpep/new/ftn_macket_record.py +++ b/models/jpep/new/ftn_macket_record.py @@ -31,9 +31,24 @@ async def _create_table(cls) -> None: remaining_amount INTEGER NOT NULL, minimum_trade_amount INTEGER NOT NULL, CONSTRAINT pk_ftn_macket_records_fetch_time_id PRIMARY KEY (fetch_time, id) - ); + ) PARTITION BY RANGE (fetch_time); """ # noqa: E501 ) + await conn.execute( + "CREATE TABLE IF NOT EXISTS ftn_macket_records_2023 PARTITION " + "OF ftn_macket_records FOR VALUES FROM ('2023-01-01 00:00:00') " + "TO ('2023-12-31 23:59:59');" + ) + await conn.execute( + "CREATE TABLE IF NOT EXISTS ftn_macket_records_2024 PARTITION " + "OF ftn_macket_records FOR VALUES FROM ('2024-01-01 00:00:00') " + "TO ('2024-12-31 23:59:59');" + ) + await conn.execute( + "CREATE TABLE IF NOT EXISTS ftn_macket_records_2025 PARTITION " + "OF ftn_macket_records FOR VALUES FROM ('2025-01-01 00:00:00') " + "TO ('2025-12-31 23:59:59');" + ) @classmethod async def insert_many(cls, data: list["FTNMacketRecord"]) -> None: