chore: Second cleanup wave - organize root directory
- Archive: 85 agent .txt files → docs/archive/agents/legacy_txt/ - Scripts: Move 110 shell scripts → scripts/ (keep deploy.sh in root) - Models: Move 18 .safetensors → ml/models/checkpoints/training_artifacts/ - Delete: 34 directories (~33GB freed) - target/, coverage_*, test artifacts - Build: Clean 14 build artifacts (.rlib, .o, .pid, binaries) - Tests: Move 14 .rs files → tests/standalone/ - SQL: Move 5 files → sql/ (keep init-db*.sql for Docker) - Wave 153: Archive to docs/archive/historical/wave153/ - Docs: Archive 9 markdown files to wave_d/reports/ and historical/ Total impact: ~34GB freed (both waves), root directory cleaned from 583 to ~40 essential files Directory count reduced from 65 to 31 (52% reduction) All historical data preserved in organized archive structure
This commit is contained in:
59
sql/trading_workload.sql
Normal file
59
sql/trading_workload.sql
Normal file
@@ -0,0 +1,59 @@
|
||||
-- Trading workload SQL for pgbench
|
||||
-- 40% INSERT, 30% SELECT, 20% UPDATE, 10% Complex queries
|
||||
|
||||
\set account_id 'test_account_' :client_id
|
||||
\set venue 'test_venue'
|
||||
\set symbol random(1, 3)
|
||||
|
||||
-- Map random number to symbol
|
||||
\if :symbol = 1
|
||||
\set symbol_str 'BTC/USD'
|
||||
\elif :symbol = 2
|
||||
\set symbol_str 'ETH/USD'
|
||||
\else
|
||||
\set symbol_str 'SOL/USD'
|
||||
\endif
|
||||
|
||||
\set operation random(1, 10)
|
||||
|
||||
-- 40% INSERT (operations 1-4)
|
||||
\if :operation <= 4
|
||||
INSERT INTO orders (account_id, symbol, side, order_type, quantity, limit_price, venue, created_at, updated_at)
|
||||
VALUES (:'account_id', :'symbol_str', 'buy', 'limit', 100000000, 5000000000000, :'venue',
|
||||
EXTRACT(EPOCH FROM NOW()) * 1000000000, EXTRACT(EPOCH FROM NOW()) * 1000000000);
|
||||
|
||||
-- 30% SELECT (operations 5-7)
|
||||
\elif :operation <= 7
|
||||
SELECT id, status, quantity, filled_quantity
|
||||
FROM orders
|
||||
WHERE symbol = :'symbol_str'
|
||||
ORDER BY created_at DESC
|
||||
LIMIT 10;
|
||||
|
||||
-- 20% UPDATE (operations 8-9)
|
||||
\elif :operation <= 9
|
||||
UPDATE orders
|
||||
SET status = 'partially_filled',
|
||||
filled_quantity = filled_quantity + 10000000,
|
||||
updated_at = EXTRACT(EPOCH FROM NOW()) * 1000000000
|
||||
WHERE id = (
|
||||
SELECT id
|
||||
FROM orders
|
||||
WHERE status = 'pending'
|
||||
AND symbol = :'symbol_str'
|
||||
LIMIT 1
|
||||
);
|
||||
|
||||
-- 10% Complex query (operation 10)
|
||||
\else
|
||||
SELECT symbol,
|
||||
COUNT(*) as order_count,
|
||||
SUM(quantity) as total_quantity,
|
||||
AVG(limit_price) as avg_price,
|
||||
COUNT(DISTINCT account_id) as unique_accounts
|
||||
FROM orders
|
||||
WHERE created_at > EXTRACT(EPOCH FROM (NOW() - INTERVAL '1 hour')) * 1000000000
|
||||
GROUP BY symbol
|
||||
ORDER BY order_count DESC;
|
||||
|
||||
\endif
|
||||
Reference in New Issue
Block a user