Running Sql Queries On Production/Live Databases - V Things To Remember

Running Sql Queries On Production/Live Databases - V Things To Remember - Hallo sahabat BEST LEARNING JAVA, Pada Artikel yang anda baca kali ini dengan judul Running Sql Queries On Production/Live Databases - V Things To Remember, kami telah mempersiapkan artikel ini dengan baik untuk anda baca dan ambil informasi didalamnya. mudah-mudahan isi postingan Artikel best practices, Artikel Microsoft SQL Server, Artikel SQL, yang kami tulis ini dapat anda pahami. baiklah, selamat membaca.

Judul : Running Sql Queries On Production/Live Databases - V Things To Remember
link : Running Sql Queries On Production/Live Databases - V Things To Remember

Baca juga


Running Sql Queries On Production/Live Databases - V Things To Remember

Did you lot ever confront a province of affairs where some of your innocuous looking activity has drive production number as well as that every bit good big time? Well, I promise you lot receive got non because it's certainly, non a pleasant experience. One of such innocuous looking activity is running SQL queries on production databases. I had that inwards yesteryear rattling early on inwards my career where I removed some config every bit duplicates exclusively to discovery afterward a calendar week that it stopped publishing messages to 1 of the downstream. When you lot move inwards complex systems which has so many components, millions of lines of code, thousands of configuration as well as many databases amongst hundreds of tables, you lot receive got to move actually careful amongst anything you lot do. Often at that spot is on the existent agency to perform a production-like testing, thence the best bet is to decease along your modify every bit much isolated as well as express every bit possible.

Anyway, all this background because today I am going to percentage some tips to you lot guys spell querying production or alive databases to foreclose production issues. Since many Java developers are non SQL experts but they create write SQL queries, stored procedures, as well as interact amongst both examination as well as production databases, at that spot is a goodness endangerment that their innocuous looking activity tin drive production issue.

Last twelvemonth at the same time, nosotros had 1 of such incident where a developer's SELECT question blocked some physical care for inwards production. The innocuous looking SELECT question holds a lock on 1 of the tables which were needed yesteryear the physical care for trying to update as well as insert the information into the same table. The developer run the question at the cease of the solar daytime as well as forgot most that, exclusively to discovery adjacent morn that some essential labor hasn't completed as well as they are running from concluding night. Eventually, DBAs were involved as well as they kill the connector which is blocking the labor as well as things were restored back.




5 Things to regard spell running SQL queries on production databases

Well, this is 1 of the extreme cases where developer forgets to cancel the question when it was taking a long fourth dimension but probability of happening something similar this is quite high, specially if you lot receive got production access as well as don't know much most locking inwards the database. The best is to improve your cognition of locking as well as isolation grade but to move prophylactic than sorry, you lot tin also follow next tips spell running SQL queries on production:


1) Always question amongst NOLOCK option
This tin drive production number if some labor is also running as well as trying to update the same tabular array you lot are querying. By proverb NOLOCK you lot trim the endangerment of blocking as well as deadlock e.g.

SELECT Id, Name, Address from Employee amongst (NOLOCK) where Id= 2

When you lot run your question amongst NOLOCK hint, it instructs question engine to non number shared locks as well as does non award exclusive locks. When you lot role amongst NOLOCK option, it is possible to read an uncommitted transaction or a fix of pages that are rolled dorsum inwards the middle of a read. Dirty reads are possible. Though, worth noting is that this choice exclusively applies to the SELECT disputation as well as available for Microsoft SQL Server. See Microsoft SQL Server T-SQL Fundamentals larn to a greater extent than most tabular array as well as row grade locking.



2) Always run your question inwards backup or secondary server
If possible, ever run your question on backup or secondary server instead of running it on the primary server. Only if merely cannot role secondary because you lot experience information is non most up-to-date role primary, but bottom job is to avoid touching the primary or principal server on production hours.


3) Test your queries on UAT earlier running on production
This is the same dominion which I powerfulness receive got told you lot earlier when explaining most UNIX commands. Similar to UNIX command which you lot should examination on Staging boxes earlier running on production machines, you lot should also commencement run your question on QA or UAT surround earlier running them inwards production. This non exclusively laissez passer on you lot a goodness thought of what to await but also salve you lot from syntax error as well as accidental mistakes inwards production.


4) Avoid touching Production database during Market hours
If you lot are working for a organisation which has some marketplace position hours e.g. stock exchanges which run from morn ix to 4 PM, as well as then you lot should avoid touching your production database during that menstruum as well as exclusively run your queries afterward marketplace position hours. There is a lot of activity goes on DB during marketplace position hours as well as at that spot is ever a goodness endangerment that your innocuous looking SELECT queries may interfere amongst them.


5) Have a iv oculus banking corporation gibe on your query
If you lot are non working lone as well as receive got some squad members, you lot tin ever inquire your colleagues to create a iv oculus banking corporation gibe on the question you lot desire to run inwards production. If you lot tin review your queries from DBAs as well as then it's fifty-fifty better.

 Did you lot ever confront a province of affairs where some of your innocuous looking activity has drive produ Running SQL Queries on Production/live Databases - v Things to Remember


That's all most some of import tips to squall back spell querying production database. You should also larn to a greater extent than most how database executes your SQL question e.g. how the index works, how locking works, tabular array scan, row scan, tabular array grade locking, or row grade locking etc. If you lot know those basics well, you lot tin predict your queries conduct to a greater extent than deterministically as well as potentially avoid unpleasant surprises. One mass which tin aid you lot hither is the SQL Performance Explained yesteryear Markus Winand, this volition laissez passer on you lot a goodness thought of the database from developer's perspective.

What most you? What tips you lot follow or what caution you lot accept spell querying production/live database?

Further Learning
list)
  • The Developer's listing of must read SQL books (list)
  • Difference betwixt where as well as having clause inwards SQL (answer)
  • The divergence betwixt wedlock as well as wedlock all inwards SQL? (answer)
  • Difference betwixt row_number, rank, as well as dense_rank inwards SQL (answer)
  • The divergence betwixt self as well as equijoin inwards SQL? (answer)
  • Thank you lot for reading this article, if you lot like, delight percentage amongst your friends as well as colleagues too. It helps a lot.


    Demikianlah Artikel Running Sql Queries On Production/Live Databases - V Things To Remember

    Sekianlah artikel Running Sql Queries On Production/Live Databases - V Things To Remember kali ini, mudah-mudahan bisa memberi manfaat untuk anda semua. baiklah, sampai jumpa di postingan artikel lainnya.

    Anda sekarang membaca artikel Running Sql Queries On Production/Live Databases - V Things To Remember dengan alamat link https://bestlearningjava.blogspot.com/2017/06/running-sql-queries-on-productionlive.html

    Belum ada Komentar untuk "Running Sql Queries On Production/Live Databases - V Things To Remember"

    Posting Komentar

    Iklan Atas Artikel

    Iklan Tengah Artikel 1

    Iklan Tengah Artikel 2

    Iklan Bawah Artikel