Skip to content

Commit f935f54

Browse files
committed
refactor: optimize whitelist table schema for performance
Migrate the `whitelist` table to `whitelist_v1` with optimized storage and indexing. This change removes the unnecessary auto-increment `id` column and uses `info_hash` directly as the PRIMARY KEY, improving both storage efficiency and query performance. Database-specific optimizations: - **SQLite**: Use `WITHOUT ROWID` optimization since info_hash is already a suitable primary key (40-char hex string). This eliminates the hidden rowid column and reduces storage overhead. - **MySQL**: Store info_hash as `BINARY(20)` instead of `VARCHAR(40)`, reducing storage from 40 bytes to 20 bytes per entry and improving index performance. Changes: - Add migration scripts for both SQLite and MySQL to: - Create new `whitelist_v1` table with optimized schema - Migrate existing data (converting hex to binary for MySQL) - Drop old `whitelist` table - Update hardcoded table creation SQL in database drivers to match new schema - Update all whitelist queries to use `whitelist_v1` table name - Update MySQL driver to use binary storage with `UNHEX()`/bytes() for info_hash operations - Document the new schema in migrations README with storage format details for both databases The migration preserves all existing whitelist data while improving storage efficiency and query performance for whitelist lookups.
1 parent 2d0c0a4 commit f935f54

6 files changed

Lines changed: 181 additions & 143 deletions

File tree

0 commit comments

Comments
 (0)