DEV Community

Pacharapol Withayasakpunt
Pacharapol Withayasakpunt

Posted on

A quick glance at PostgreSQL (Node.js driver) - better than doc-type NoSQL, and too good to be true

And I like it more than not like it, that is it like NoSQL in "strict mode".

  • TEXT[] with JSONB index or GIN index is supported.
  • ARRAY, JSONB and TIMESTAMP, with automatic conversion to-and-back JavaScript Objects, Array, Object and Date.
  • Unsurprisingly, ALTER TABLE ADD COLUMN is supported.

No, I don't use standard Postgres this time

I don't know if MongoDB supports extensions, but Postgres does, and even third parties.

I am talking about non-English full text search, in Chinese and Japanese; using https://pgroonga.github.io

Dockerfile

FROM postgres:13
RUN apt-get update
RUN apt-get install -y wget

WORKDIR /app
RUN wget https://packages.groonga.org/debian/groonga-apt-source-latest-buster.deb
RUN apt-get install -y ./groonga-apt-source-latest-buster.deb
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ buster-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list
RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
RUN apt-get update
RUN apt-get install -y postgresql-13-pgdg-pgroonga
RUN apt-get install -y groonga-tokenizer-mecab
Enter fullscreen mode Exit fullscreen mode

docker-compose.yml

version: "3"
services:
  db:
    build: ./packages/db
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgress
      - POSTGRES_DB=postgres
    ports:
      - "5433:5432"
    volumes:
      - pgdata:/var/lib/postgresql/data
volumes: 
  pgdata:
Enter fullscreen mode Exit fullscreen mode

So, what did I really install on my machine?

I did install Postgres on my machine to test it first; but I don't think it is really needed.

More importantly,

  • pgAdmin

I still want better full-text search.

What about

  • Column specific search, if wanted
  • Non-text search query string

I am positive I can create my own query language, as I have done it before; but what matters more here is performance... as I am privileged
enough to have today.

And, yeah, MongoDB does have full-text index; but it is very primitive to me.

Top comments (0)