Skip to content

Commit

Permalink
Merge pull request #202 from NEOS-AI/dev
Browse files Browse the repository at this point in the history
Learn more details for better Postgres based search engine
  • Loading branch information
YeonwooSung authored Dec 14, 2024
2 parents c21257d + c8ceacb commit 7407d05
Show file tree
Hide file tree
Showing 6 changed files with 17,488 additions and 0 deletions.
11 changes: 11 additions & 0 deletions postgres/electric/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Electric

[Electric](https://github.com/electric-sql/electric) is a Postgres sync engine. It does real-time partial replication of Postgres data into local apps and services.

## Running Insturction

### Docker

```bash
docker compose -f docker_compose/docker-compose.yml up
```
32 changes: 32 additions & 0 deletions postgres/electric/docker_compose/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
version: "3.3"
name: "electric_example-${PROJECT_NAME:-default}"

services:
postgres:
image: postgres:16-alpine
environment:
POSTGRES_DB: electric
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
ports:
- 54321:5432
volumes:
- ./postgres.conf:/etc/postgresql/postgresql.conf:ro
tmpfs:
- /var/lib/postgresql/data
- /tmp
command:
- postgres
- -c
- config_file=/etc/postgresql/postgresql.conf

backend:
image: electricsql/electric:canary
environment:
DATABASE_URL: postgresql://postgres:password@postgres:5432/electric?sslmode=disable
ports:
- 3000:3000
build:
context: ../packages/sync-service/
depends_on:
- postgres
2 changes: 2 additions & 0 deletions postgres/electric/docker_compose/postgres.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
listen_addresses = '*'
wal_level = logical # minimal, replica, or logical
19 changes: 19 additions & 0 deletions postgres/paradedb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,22 @@ paradedb/paradedb
If you want to customize the values, please refer [ParadeDB Docs](https://github.com/paradedb/charts/tree/main/charts/paradedb).

For more information, please refer to the [ParadeDB github repo](https://github.com/paradedb/charts).

## See details of Stored Procedures

ParadeDB provides a set of stored procedures for searching and indexing.
In psql, you could run `\df+ <function_name> ` to see the details of the stored procedure.

Also, you could run the query below to print out all stored procedures in the database:
```bash
sudo docker exec paradedb psql -U postgres -d postgres -c "
SELECT
n.nspname as schema_name,
p.proname as procedure_name,
pg_get_functiondef(p.oid) as definition
FROM pg_proc p
INNER JOIN pg_namespace n ON p.pronamespace = n.oid
WHERE n.nspname NOT IN ('pg_catalog', 'information_schema')
AND p.prokind = 'f' -- Only select normal functions (not aggregate or window functions)
ORDER BY schema_name, procedure_name;" > ./procedures_paradedb.sql
```
11 changes: 11 additions & 0 deletions postgres/paradedb/extract_all_stored_procedures.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Extract all stored procedures
sudo docker exec paradedb psql -U postgres -d postgres -c "
SELECT
n.nspname as schema_name,
p.proname as procedure_name,
pg_get_functiondef(p.oid) as definition
FROM pg_proc p
INNER JOIN pg_namespace n ON p.pronamespace = n.oid
WHERE n.nspname NOT IN ('pg_catalog', 'information_schema')
AND p.prokind = 'f' -- Only select normal functions (not aggregate or window functions)
ORDER BY schema_name, procedure_name;" > ./procedures_paradedb.sql
Loading

0 comments on commit 7407d05

Please sign in to comment.