# PostgreSQL
Postgres can store [[json|JSON]] in it.
```sql
SELECT content -> 'type' AS content_type FROM rich_content;
SELECT DINSTINCT CAST (content -> 'type' AS TEXT) -- cast JSON objects to text
AS content_type FROM rich_content;
SELECT DINSTINCT content ->> 'type' -- ->> casts as text
AS content_type FROM rich_content;
SELECT content -> 'dimensions' AS content_type FROM rich_content
WHERE content ->> 'diemensions' IS NOT NULL
SELECT
content -> 'dimensions' ->> 'height' AS height,
content -> 'dimensions' ->> 'width' AS width
FROM rich_content WHERE content -> 'dimensions' IS NOT NULL;
EXPLAIN ... -- stats
```
```postgresql
CREATE INDEX ON comments (board_id);
CREATE UNIQUE INDEX username_idx ON users(username);
```