You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please note that the `FLAT` layout expects the primary key to be a number which can be converted to `uint64`. If the primary key is not a number, such as a string, you should switch to the `HASHED` or `COMPLEX_KEY_HASHED` layout.
148
+
147
149
#### HASHED
148
150
The `HASHED` layout stores the dictionary data in a hash table. This layout provides better memory usage than the `FLAT` layout, with slightly lower performance. The dictionary can contain any number of elements with any identifiers.
Please note that the `HASHED` layout expects the primary key to be a number which can be converted to `uint64`. If the primary key is not a number, such as a string, Timeplus will automatically switch to the `COMPLEX_KEY_HASHED` layout. Such optimization is available for other CACHE/HASHED layouts, but not `FLAT` layout.
161
+
158
162
#### SPARSE_HASHED
159
163
The `SPARSE_HASHED` layout is similar to the `HASHED` layout, but it is optimized for sparse data. It uses less memory than the `HASHED` layout.
160
164
@@ -539,6 +543,27 @@ ON orders.customer_id = customers.c_custkey
539
543
SETTINGS join_algorithm ='direct';
540
544
```
541
545
546
+
### Create a dictionary from a PostgreSQL table {#create_dictionary_pg}
547
+
548
+
For example, you can create a dictionary, referencing a PostgreSQL table:
549
+
550
+
```sql
551
+
CREATE DICTIONARY dict_pg_table (
552
+
ip string,
553
+
desc string
554
+
)
555
+
PRIMARY KEY ip
556
+
SOURCE(POSTGRESQL(HOST 'pg.aivencloud.com' PORT 28851 USER 'avnadmin' PASSWORD '..' TABLE 'ip' DB 'defaultdb'))
557
+
LIFETIME(0)
558
+
LAYOUT(COMPLEX_KEY_HASHED());
559
+
```
560
+
561
+
Then you can query the dictionary with the `dict_get` function:
0 commit comments