Skip to content

Commit

Permalink
perf: 使用分区表优化简书积分兑换平台市场记录表性能
Browse files Browse the repository at this point in the history
  • Loading branch information
FHU-yezi committed Nov 1, 2024
1 parent 2724d48 commit 1552565
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion models/jpep/new/ftn_macket_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 1552565

Please sign in to comment.