Asking For SQL Tips From OpenAI ChatGPT

Words
226
Reading
2 min
Listen
Play
4y

So I decided to try out the latest hot new thing with OpenAI ChatGPT.

Since I use SQL to query things related to Hive, I decided to ask for a tips how to improve one of my queries.

It is is a simple query..... here it is:

image.png

https://chat.openai.com/chat

It gave me four tips!
Nice!

  1. The use or no use of the NOLOCK statement is something I'm aware of, but I do it intentionally, since the database is being updated continuously as the chain goes.

  2. Use index is also something I'm aware of, but till now the reading times for this query has been fast and there haven't been need to do it. I might implement it in some other queries though.

  3. Using parameters, as example for dates, might be a good thing, but its not that hard for me to change it directly in the date section instead of having separate parameters where to change it.

  4. Optimize the query. Arranging the lines in proper order might be useful and result in faster execution.

So there you go. You can now ask AI to give you coding tips and review your code!

The tips above are not essential for the query to work, but overall they are all good tips for implementing a proper working practices.

At least I know I haven't done some super dumb thing :)

Asking For SQL Tips From OpenAI ChatGPT | Ecency