How to store and query JSON data in Postgres

Поділитися
Вставка
  • Опубліковано 14 жов 2024

КОМЕНТАРІ • 23

  • @dshukertjr
    @dshukertjr 5 місяців тому +6

    JSON columns in Postgres are so useful, but so are other data types. What is the next data type that you want us to go deep on? Let us know in the comment below 👇

    • @郭流芳
      @郭流芳 5 місяців тому +1

      Clear explanation, appropriate examples, looking forward to an example explaining the use of JSONB in a chat session application.

    • @Jebusankel
      @Jebusankel 5 місяців тому +1

      Where I think supabase really shines is using postgres json functions like json_agg() and row_to_json() to create nested structures.

  • @deldridg
    @deldridg 22 дні тому

    Nice one Tyler and thank you for the primer. I'm currently looking into using Postgres JSON in a Django project which will potentially greatly simplify the querying. I have a huge db of products in product classes, each class with its own set of unique attributes which need to be searchable. It will have a large global userbase, so I have to get this decision right. You have been a big help. Cheers from Sydney - Dave

  • @EnesKab
    @EnesKab 5 місяців тому +5

    A great use case for JSON in the SQL database can be a column which stores set of settings for something like custom styles. Let's say you have 3 styles that your user can customize and you want to store them in the database. For example, custom background color, font-size and font-weight. You can create a JSON object to store all these settings without having to create columns for each in a new table and create a relationship between the user. Also, if you create a JSON object for your user's settings, you can manipulate it way easier, add new styles in the future even if they are 20 more and do not need to worry about the performance, and best of all 👉🏻 All is possible without creating a mess in your db.

    • @dshukertjr
      @dshukertjr 5 місяців тому +1

      User preferences are a great use case for using JSONB columns!

  • @jannickpedersen4620
    @jannickpedersen4620 5 місяців тому +9

    NextJS14 + Supabase + ShadCN + TailwindCSS = The Big Guy

  • @xberna8156
    @xberna8156 5 місяців тому +3

    Nice explanation, thank you!

    • @dshukertjr
      @dshukertjr 5 місяців тому

      Glad to hear you found it helpful!

  • @thestereokid6073
    @thestereokid6073 4 місяці тому +2

    how big can these objects go and still be performant?
    I'm working on a system that has some really big json documents tracking interactions but we have migrated to a postgreSQL DB from a mongo DB and now we aren't sure if we can handle the big documents in our collections.
    Any advice?

  • @planetmall2
    @planetmall2 5 місяців тому +2

    This was awesome!

  • @jaany
    @jaany 5 місяців тому +2

    Great video!

  • @cariyaputta
    @cariyaputta 5 місяців тому +2

    Thanks.

  • @vengateshm2122
    @vengateshm2122 5 місяців тому +8

    Seems we can wrap no sql into sql world.

    • @Supabase
      @Supabase  5 місяців тому +2

      Best of both ❤️

  • @nicolascalderon9366
    @nicolascalderon9366 5 місяців тому

    How would performance impact the search and database writing when using jsonb vs regular columns?

    • @Supabase
      @Supabase  5 місяців тому +1

      With proper indexes, the difference in speed of querying data from a joined table and jsonb column are negligible. Writing is the same, generally the performance difference should be negligible. You should choose whether to use JSONB or not depending on wha tthe data could look like. If you want to be a bit more flexible with the schema of the data, you can choose to use JSONB.

  • @jonathangamble
    @jonathangamble 5 місяців тому +1

    can you fo joins?

    • @dshukertjr
      @dshukertjr 5 місяців тому +2

      Yes, you can join a table with another table using JSON values too!

  • @emmanuelchucks
    @emmanuelchucks 5 місяців тому

    Is it just me or does the voice sound AI generated?

    • @dshukertjr
      @dshukertjr 5 місяців тому +2

      I swear nothing was AI generated 😂 Maybe the bad sound quality at the intro and outro are making you feel that way. I will try to improve it on the next recording!

    • @punkgurutv
      @punkgurutv 5 місяців тому +3

      @@dshukertjr The sound quality is really good. I think he just means your voice is so peaceful and well-measured that it seems as if an A.I. super intelligence is responsible for it.

    • @tylershukert3621
      @tylershukert3621 5 місяців тому +1

      @@punkgurutv That is so sweet of you!