Thursday, July 18, 2019

SQL Server ReIndexing Jobs fail due to full transaction logs


We've encountered issues with a couple of our customers wherein, as that database grows, index maintenance becomes difficult to manage.
In some cases, because the indexes become quite large, the index rebuilds on badly fragmented indexes fill the transaction logs.

For one of our customers, we resolved it in part by altering the recovery model to be BULK LOGGED during the index maintenance.
Index Rebuild operations qualify as a minimally logged operation, and can therefore take advantage of reduced logging in BULK LOGGED recovery model.

I wanted to do some research or testing before I recommended this, because it’s a big deal to change recovery models, do index maintenance, and then switch back.
I did find a link to someone else who did some testing, though, and found that using bulk logged would, indeed, reduce log file growth during  re-indexing.

(Thanks to Balmukund for running and publishing this test!!!)

For his test Balmukund used Adventure Works, of course 😉. Classic 😀

In FULL RECOVERY MODE, the DBCC Reindex used about 100 MB space. 
(by my math using rounding: 41-2 = 39% used. 258 *.39 = 100.62)

In BULK LOGGED, it used about 2.5 MB.  
(again, rounding: 4.77- 2.98 = 1.8% of 258 is 2.58.)

This is a *VERY* significant difference. 
While I understand that switching back and forth between FULL and BULK LOGGED recovery model is scary, this remains something  to keep in our hip pocket when index maintenance is filling the transaction log! 

TODO: Verify that partitioning the table/index (es) involved will not also help this situation. My guess is that it will not, because there is only one transaction log for a database in sql server, and logging is logging. Still, I'd like to test the theory.

Someday 😏



Wednesday, July 17, 2019

LABELS not working in .bat file. Error: The system cannot find the batch label specified

I've often run across the issue where
- I write a .bat file with a label.
- The label is quite valid
- The system throws the error: The system cannot find the batch label specified

I've found this to be an issue of line terminators.
I typically use Notepad++ for editing .bat files. It tends to use Unix line terminators. (Just LF, or \n)
I need to change these to be \r\n (carriage return & new line)

This also seems to impact statement blocks for IF statements.
Example:
IF "%1"=="SomeValue"(
  echo %1
  echo I just echoed %1
  set myvalue=%1
)

I have not carefully tested, but I get the same sort of weird errors for perfectly valid statements. I'm guessing they're related.

Best of luck!

DBT-50000 when using DBCA.bat on Windows (Oracle 19.11)

I’ve been having some trouble getting DBCA to run in order to create databases. Thought I’d share it with you, and thus document it for la...