SQL indexing best practices | How to make your database FASTER!

แชร์
ฝัง
  • เผยแพร่เมื่อ 22 ก.ค. 2024
  • Learn about best practices for using indexes in SQL, and how they can be used to speed up your queries, make your database faster, and improve your application's performance.
    Try CockroachDB serverless (it's free): cockroachlabs.cloud/signup
    0:00 Intro
    0:05 Example database table
    0:15 Example query
    0:21 The problem with a full table scan
    0:50 Using EXPLAIN ANALYZE
    1:04 What is a SQL index?
    1:17 How to create a single-column index
    1:37 How to create a multi-column index
    2:08 Optimizing our SQL query
    2:31 Caveats of sql indexes
    Blog: www.cockroachlabs.com/blog/sq...
    Docs: www.cockroachlabs.com/docs/st...
    Free Course: university.cockroachlabs.com/...
  • บันเทิง

ความคิดเห็น • 25

  • @drugofsweetness
    @drugofsweetness หลายเดือนก่อน +3

    "When in doubt, explain" is what i loved about this video.

  • @electrolyteorb
    @electrolyteorb ปีที่แล้ว +2

    Great video 🎉 you are just teaching Not only for CRDB but Sql dbs in general 👍

  • @jeswer9
    @jeswer9 ปีที่แล้ว +8

    Someone that talks sense. Great info!

  • @WhiteSiroi
    @WhiteSiroi 10 หลายเดือนก่อน

    thank you very much, very helpful

  • @AnatolyLeonov
    @AnatolyLeonov ปีที่แล้ว +1

    Thanks! This was a nice enlightening explanation!

  • @umabharathyts1998
    @umabharathyts1998 3 ชั่วโมงที่ผ่านมา

    Thanks !

  • @hasanmougharbel8030
    @hasanmougharbel8030 ปีที่แล้ว

    Hello man,
    God bless your efforts.
    I have a simple enquiry as a new sql learner.
    How does the term b-tree relate to the index function in sql?
    Thanks for taking care of this.

  • @ExcelTutorials1
    @ExcelTutorials1 ปีที่แล้ว +2

    Very helpful, thank you!

  • @MagicOfDark
    @MagicOfDark 9 หลายเดือนก่อน +5

    I had table without index took 18 hours to run, with index took like 6 minutes. Table had millions of entries. Also made some changes to my code, but that only shaved like 1-2 hours off.

    • @Shujahaidergaming
      @Shujahaidergaming 2 หลายเดือนก่อน

      How it happens . It a alot of margin 6 hours and 6 minutes.
      How much data in your table ?

  • @abhay6276
    @abhay6276 2 หลายเดือนก่อน +1

    You didn't mention which index you created ? Clustered or non Clustered?😊

  • @Deltacasper
    @Deltacasper ปีที่แล้ว

    Would it not have been more efficient to create a separate table for the city column with additional information about the city such as region and country and reference that by Id and then index based on that instead and additionally have less redundant data or how?

    • @michealraspberry4138
      @michealraspberry4138 7 หลายเดือนก่อน +1

      correct. for data that repeat, what you suggested is the right solution. however, this is an example situation and they are trying to explain how indices are used.

  • @teja6124
    @teja6124 ปีที่แล้ว

    Hi Sir, I have a table that consist of 16mil record and it will increase, weekly basis. to retrieve this table in Powerbi it is taking more time get this data from large SQL table. can you suggest any changes on the existing table ? current table doesn't have any indexes.

    • @maryadebimpe9424
      @maryadebimpe9424 4 หลายเดือนก่อน +1

      Alter the table syntax an add the index

  • @Nodsaibot
    @Nodsaibot 10 หลายเดือนก่อน

    oooooooor create a JSON with the cached results :D

  • @jenweatherwax7113
    @jenweatherwax7113 5 หลายเดือนก่อน

    How many indexes should one add? And how do you know which columns to choose?

    • @MatheusLB2009
      @MatheusLB2009 หลายเดือนก่อน

      Maybe too late but indexes have to be unique (otherwise there is conflict) and preferably small as he said in the video. And if there is none, having a table mostly sorted by a specific column, like DateTime, naturally speeds up the query

  • @victoriasingveena441
    @victoriasingveena441 7 หลายเดือนก่อน +1

    Cool

    • @cockroachdb
      @cockroachdb  7 หลายเดือนก่อน

      We couldn't agree more.

  • @user-sf8cs3sz2i
    @user-sf8cs3sz2i 9 หลายเดือนก่อน +1

    Love this video HATE the name cockroach, disgusting

    • @rainymornings
      @rainymornings 7 หลายเดือนก่อน +1

      I felt the same but honestly aren't they just insects like every other? I feel sad for the little critters now lol

    • @user-sf8cs3sz2i
      @user-sf8cs3sz2i 7 หลายเดือนก่อน

      @@rainymornings Appreciate your sentiment, still HATE roaches.