diff --git a/README.md b/README.md index 1b0df6d..d0690e1 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,14 @@ # ShopMC MC Shop - +## Logging +This plugin records shop transactions either to a local YAML file or to a +MySQL database. Logging and lookups run asynchronously to avoid blocking the +server thread. When using MySQL, the table is created with indexes on the +player and timestamp columns to keep queries fast. ## Commands - `/shop [buy|price|search|admin]` – Buy from the server shop or open GUI - `/sell ` – Sell to the server shop - `/sellall` – Sell all sellable items in your inventory - `/shoplog [player] [limit]` – View transaction log - `/weeklyshop` – Show weekly shop items + diff --git a/src/main/java/com/yourorg/servershop/logging/SQLLogStorage.java b/src/main/java/com/yourorg/servershop/logging/SQLLogStorage.java index 7d35134..43f766b 100644 --- a/src/main/java/com/yourorg/servershop/logging/SQLLogStorage.java +++ b/src/main/java/com/yourorg/servershop/logging/SQLLogStorage.java @@ -33,6 +33,8 @@ private void init() throws Exception { "amount DOUBLE NOT NULL," + "INDEX idx_player_time (player, time_ms)" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4"); + // Ensure efficient global queries by indexing by time as well + st.executeUpdate("CREATE INDEX IF NOT EXISTS idx_time_ms ON servershop_transactions(time_ms)"); } }