Skip to content

Instantly share code, notes, and snippets.

@pdeaudney
Created July 17, 2023 23:04
Show Gist options
  • Save pdeaudney/28d991c3831c2f5963461dd47669bedd to your computer and use it in GitHub Desktop.
Save pdeaudney/28d991c3831c2f5963461dd47669bedd to your computer and use it in GitHub Desktop.
there is no parameter $1 error
iot_devicereadings=# \d+ iot.device_reading
Table "iot.device_reading"
Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description
-----------+-----------------------------+-----------+----------+---------+----------+-------------+--------------+-------------
asset_id | character varying(36) | | not null | | extended | | |
vendor | character varying(36) | | not null | | extended | | |
vendor_id | character varying(36) | | not null | | extended | | |
type | character varying(36) | | not null | | extended | | |
value | real | | not null | | plain | | |
created | timestamp without time zone | | not null | | plain | | |
Indexes:
"device_reading_pk" PRIMARY KEY, btree (asset_id, type, created)
"device_reading_asset_id_created_idx" btree (asset_id, created)
"device_reading_created_idx" btree (created)
Access method: heap
iot_devicereadings=# \dx
List of installed extensions
Name | Version | Schema | Description
--------------------+---------+------------+------------------------------------------------------------------------
citus | 11.2-2 | pg_catalog | Citus distributed database
citus_columnar | 11.1-1 | pg_catalog | Citus Columnar extension
pg_buffercache | 1.3 | public | examine the shared buffer cache
pg_repack | 1.4.8 | public | Reorganize tables in PostgreSQL databases with minimal locks
pg_stat_statements | 1.9 | public | track planning and execution statistics of all SQL statements executed
pgaudit | 1.6.2 | public | provides auditing functionality
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
uuid-ossp | 1.1 | public | generate universally unique identifiers (UUIDs)
(8 rows)
iot_devicereadings=# select version();
version
-----------------------------------------------------------------------------------------------------------------------------------
PostgreSQL 14.8 (Ubuntu 14.8-1.pgdg20.04+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0, 64-bit
(1 row)
iot_devicereadings=# select * from citus_tables; -- there are other sharded tables
table_name | citus_table_type | distribution_column | colocation_id | table_size | shard_count | table_owner | access_method
--------------------------------+------------------+---------------------+---------------+------------+-------------+-----------------------------+---------------
iot.device_reading | distributed | asset_id | 5 | 173 GB | 48 | iot_devicereadingsavercitus | heap
@pdeaudney
Copy link
Author

2023-07-17 01:30:37.418 UTC [1843972] iot_stats@iot_devicereadings ERROR:  there is no parameter $1 at character 24
2023-07-17 01:30:37.418 UTC [1843972] iot_stats@iot_devicereadings CONTEXT:  unnamed portal with parameters: $1 = '2023-07-16 01:30:37.329811Z', $2 = 'pixel', $3 = 'byo_monnit'
2023-07-17 01:30:37.418 UTC [1843972] iot_stats@iot_devicereadings STATEMENT:
			SELECT r.vendor, COUNT(r.vendor_id) as "count"
			FROM (
				SELECT DISTINCT vendor, vendor_id
				FROM iot.device_reading
				WHERE created >= $1 AND vendor IN ($2, $3)
			) r
			GROUP BY r.vendor

@pdeaudney
Copy link
Author

2023-07-18 19:47:07.035 UTC [2676794] iot_stats@iot_devicereadings LOG:  duration: 0.103 ms  parse <unnamed>:
                        SELECT r.vendor, COUNT(r.vendor_id) as "count"
                        FROM (
                                SELECT DISTINCT vendor, vendor_id
                                FROM iot.device_reading
                                WHERE created >= $1 AND vendor IN ($2, $3, $4, $5)
                        ) r
                        GROUP BY r.vendor

2023-07-18 19:47:07.038 UTC [2676794] iot_stats@iot_devicereadings LOG:  duration: 0.983 ms  bind <unnamed>:
                        SELECT r.vendor, COUNT(r.vendor_id) as "count"
                        FROM (
                                SELECT DISTINCT vendor, vendor_id
                                FROM iot.device_reading
                                WHERE created >= $1 AND vendor IN ($2, $3, $4, $5)
                        ) r
                        GROUP BY r.vendor

2023-07-18 19:47:07.038 UTC [2676794] iot_stats@iot_devicereadings DETAIL:  parameters: $1 = '2023-07-18 19:17:07.034892', $2 = 'monnit', $3 = 'definium', $4 = 's12test', $5 = 'mydevices'
2023-07-18 19:47:07.057 UTC [2679675] postgres@assets LOG:  duration: 0.302 ms  statement: SELECT waiting_pid, waiting_node_id, waiting_transaction_num, waiting_transaction_stamp, blocking_pid, blocking_node_id, blocking_transaction_num, blocking_transaction_stamp, blocking_transaction_waiting FROM dump_local_wait_edges()
2023-07-18 19:47:07.093 UTC [2679676] postgres@iot_devicereadings LOG:  duration: 0.366 ms  statement: SELECT waiting_pid, waiting_node_id, waiting_transaction_num, waiting_transaction_stamp, blocking_pid, blocking_node_id, blocking_transaction_num, blocking_transaction_stamp, blocking_transaction_waiting FROM dump_local_wait_edges()
2023-07-18 19:47:07.104 UTC [2679763] postgres@inspections LOG:  duration: 0.304 ms  statement: SELECT waiting_pid, waiting_node_id, waiting_transaction_num, waiting_transaction_stamp, blocking_pid, blocking_node_id, blocking_transaction_num, blocking_transaction_stamp, blocking_transaction_waiting FROM dump_local_wait_edges()
2023-07-18 19:47:07.138 UTC [2676794] iot_stats@iot_devicereadings ERROR:  there is no parameter $1 at character 24
2023-07-18 19:47:07.138 UTC [2676794] iot_stats@iot_devicereadings CONTEXT:  unnamed portal with parameters: $1 = '2023-07-18 19:17:07.034892Z', $2 = 'monnit', $3 = 'definium', $4 = 's12test', $5 = 'mydevices'
2023-07-18 19:47:07.138 UTC [2676794] iot_stats@iot_devicereadings STATEMENT:
                        SELECT r.vendor, COUNT(r.vendor_id) as "count"
                        FROM (
                                SELECT DISTINCT vendor, vendor_id
                                FROM iot.device_reading
                                WHERE created >= $1 AND vendor IN ($2, $3, $4, $5)
                        ) r
                        GROUP BY r.vendor

2023-07-18 19:47:07.144 UTC [2676794] iot_stats@iot_devicereadings LOG:  duration: 0.137 ms  parse <unnamed>:
                        SELECT r.vendor, COUNT(r.vendor_id) as "count"
                        FROM (
                                SELECT DISTINCT vendor, vendor_id
                                FROM iot.device_reading
                                WHERE created >= $1 AND vendor IN ($2, $3, $4, $5)
                        ) r
                        GROUP BY r.vendor

2023-07-18 19:47:07.147 UTC [2676794] iot_stats@iot_devicereadings LOG:  duration: 0.990 ms  bind <unnamed>:
                        SELECT r.vendor, COUNT(r.vendor_id) as "count"
                        FROM (
                                SELECT DISTINCT vendor, vendor_id
                                FROM iot.device_reading
                                WHERE created >= $1 AND vendor IN ($2, $3, $4, $5)
                        ) r
                        GROUP BY r.vendor

2023-07-18 19:47:07.147 UTC [2676794] iot_stats@iot_devicereadings DETAIL:  parameters: $1 = '2023-07-17 19:47:07.143548', $2 = 'monnit', $3 = 'definium', $4 = 's12test', $5 = 'mydevices'
2023-07-18 19:47:07.175 UTC [2676794] iot_stats@iot_devicereadings LOG:  duration: 28.910 ms  execute <unnamed>:
                        SELECT r.vendor, COUNT(r.vendor_id) as "count"
                        FROM (
                                SELECT DISTINCT vendor, vendor_id
                                FROM iot.device_reading
                                WHERE created >= $1 AND vendor IN ($2, $3, $4, $5)
                        ) r
                        GROUP BY r.vendor

2023-07-18 19:47:07.175 UTC [2676794] iot_stats@iot_devicereadings DETAIL:  parameters: $1 = '2023-07-17 19:47:07.143548', $2 = 'monnit', $3 = 'definium', $4 = 's12test', $5 = 'mydevices'

@pdeaudney
Copy link
Author

iot_devicereadings=# select * from citus_tables where table_name::text = 'iot.device_reading';
     table_name     | citus_table_type | distribution_column | colocation_id | table_size | shard_count |         table_owner         | access_method
--------------------+------------------+---------------------+---------------+------------+-------------+-----------------------------+---------------
 iot.device_reading | distributed      | asset_id            |            11 | 6081 MB    |          48 | iot_devicereadingsavercitus | heap
(1 row)

iot_devicereadings=# \d+ iot.device_reading
                                                   Table "iot.device_reading"
  Column   |            Type             | Collation | Nullable | Default | Storage  | Compression | Stats target | Description
-----------+-----------------------------+-----------+----------+---------+----------+-------------+--------------+-------------
 asset_id  | character varying(36)       |           | not null |         | extended |             |              |
 vendor    | character varying(36)       |           | not null |         | extended |             |              |
 vendor_id | character varying(36)       |           | not null |         | extended |             |              |
 type      | character varying(36)       |           | not null |         | extended |             |              |
 value     | real                        |           | not null |         | plain    |             |              |
 created   | timestamp without time zone |           | not null |         | plain    |             |              |
Indexes:
    "device_reading_pk" PRIMARY KEY, btree (asset_id, type, created)
    "device_reading_asset_id_created_idx" btree (asset_id, created)
    "device_reading_created_idx" btree (created)
Access method: heap

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment