psql
:
event
definitions in your Main.sol
contract.
event
in your listener creates a corresponding queryable view in the database. The view name is the lowercase snake_case
version of the event name.snake_case
.pool_created_X3rbm4nC
) and should not be queried directly.event PoolCreated(address pool, address token0, address token1)
will result in a queryable view named pool_created
with the columns pool
, token0
, and token1
.
When you inspect your database, you will see both the clean views you should query and the internal tables with random suffixes. Always query the views (lowercase snake_case
names).
psql
.
To list all indexes in the database, use the \di
command. This shows the index name, type, and the table it belongs to.
To see the indexes for a specific table, use the \d "view_name"
command. This describes the view and lists the indexes on its underlying table.
psql
commands you can use to inspect your database:
Operation | psql Command | Description |
---|---|---|
List Views | \dv | Shows all queryable views in the public schema. |
Describe View | \d "view_name" | Displays the columns, types, and structure for a specific view, including indexes on the underlying table. |
List Indexes | \di | Shows all indexes in the database. |
View Sample Data | SELECT * FROM "view_name" LIMIT 10; | Retrieves the first 10 rows from a view. |
Count Rows | SELECT COUNT(*) FROM "view_name"; | Counts the total number of records indexed in a view. |