The Database Countryside Code: Best Practices for BI & SQL Users
Those ‘City Folk’ among you may not be aware but in Rural England we have what is called The Countryside Code, it’s a set of guidelines that everyone should follow in order to keep the countryside clean, tidy and a nice place to visit. You may be asking – what does this have to do with Business Intelligence and Database Administration? Well, I think it’s vital – if we all follow a fairly simple but broad set of guidelines then all classes of database user will have a better experience from Developers to DBAs and Analysts to CIOs. This isn’t really about making your databases perform better, it’s about working better with each-other and taking other people’s perspectives on board. Having been in most of the related roles over the years this is what I’d put into The Database Countryside Code…
Categories: Business Intelligence, DBA Tags: BI, DBA, logging, performance, Security, sql
Quick Tip – PostgreSQL Equivalent of ISNUMERIC()
Very much like my previous MySQL ISNUMERIC() post I have recently been setting up a data source to collect records with telephone numbers from a Postgres database and one of the essential validation tests is to make sure that the field really does contain a number.
Despite the fact that many regard Postgres as the best open source database platform I find myself frustrated by it’s lack of standard functions. I understand that Postgres is designed to be extensible and that user defined functions can be built but I need my code to be both portable and read-only so I have to work with what I’m given. Ideally what I’d be looking for is an equivalent of Microsoft SQL Server’s ISNUMERIC() or Excel’s ISNUMBER() functions but very much like MySQL I had to turn to regular expressions although as you’ll see, Postgres does not have a clean and clear REGEXP() function…
SELECT DISTINCT contact_number
FROM customers
WHERE (contact_number ~ ‘^[0-9]+$’)
I hope that helps any of you out there that encounter the same problem, thanks to the poster here for my original answer.
Categories: DBA, PostgreSQL Tags: ISNUMERIC, MySQL, Postgres, PostgreSQL, RegExp, Regular Expressions, sql
Using MySQL BLOB Data via ODBC in SSIS, SQL Server & Business Objects
Whilst trying to build a centralised cross-platform alerting system I spotted a peculiar issue when trying to move the output of a SHOW FULL PROCESSLIST command on MySQL via ODBC. It seems that the output of the SHOW FULL PROCESSLIST command returns both integers and binary (BLOB) data types even though to they eye (that is, in the MySQL Query Browser) most of the columns appear to be short text fields.
Despite the fact that the data looks like text whenever I tried to return the data into an application, I tried SSIS, SQL Server Linked Servers and Business Objects, each time the data would come back unusable or an error would be returned. Business Objects gave me the key by declaring “This is a BLOB.” as you can see in the following screenshots…
SQL Server Integration Services

SQL Server Linked Server

Business Objects Desktop Intelligence

As with my recent post about loading data into MySQL with SSIS the saviour turns out to be an ODBC configuration setting, this time in the Metadata tab of the MySQL ODBC driver. All you have to do is check the “Always handle binary function results as character data” and instantly your problems will be solved…

Out of a crazy fit of completeness I also took screenshots of the final results and it’d be a shame to waste them so here they are…
SQL Server Integration Services

SQL Server Linked Server

Business Objects Desktop Intelligence

Categories: Business Objects, DBA, Microsoft SQL Server, MySQL, Open Source, SSIS Tags: binary, blob, business objects, DBA, ETL, Integration Services, mys, MySQL, ODBC, SQL Server, SSIS
Using SQL Server 2008 R2 Linked Servers with PostgreSQL 64-bit
Having setup a Linked Server in Management Studio talking to a PostgreSQL 8 database I encountered the following error when attempting to run any valid query:
Msg 7399, Level 16, State 1, Line 1 The OLE DB provider "MSDASQL" for linked server "PG_SERVER" reported an error. The provider reported an unexpected catastrophic failure. Msg 7350, Level 16, State 2, Line 1 Cannot get the column information from OLE DB provider "MSDASQL" for linked server "PG_SERVER".
After some digging I came across a handy article on Microsoft Connect describing the same issue, with thanks to Nenea Nelu here’s the solution…
- Expand Server Objects > Linked Servers > Providers.

- Right-click on MSDASQL and select Properties…
- In the Properties dialogue un-check “Allow inprocess” as follows…

- Click OK and re-run your query.
Hopefully that should solve your problem, please note that this will affect all Linked Servers using that provider however as the Connect article points out – this is best practice for linked servers anyway.
Categories: DBA, Microsoft SQL Server, PostgreSQL Tags: 2008 R2, Linked Servers, MSDASQL, OLE DB, Postgres, PostgreSQL, SQL Server
SQL Server Backup Compression vs. Quest Litespeed Engine
As more and more functionality is built into products like SQL Server it’s always worthwhile reviewing third-party tools and utilities when you’re considering an upgrade to see (a) if they’re still required and (b) if the tools themselves need to be upgraded. With the introduction of Backup Compression in SQL Server 2008 R2 Standard Edition you could begin to think that the future is grim for Quest’s backup compression software LiteSpeed so I thought I’d do some testing to see exactly how it stacks up against the native compression.
LiteSpeed Engine
I’ve been using LiteSpeed on and off for a few years now and it has always been a great tool but I’ve always found it a bit of a drag to have to use the GUI to administer and setup jobs however in January 2010 Quest launched the LiteSpeed Engine for SQL Server which allows you to administer jobs using the native SQL Server tools. The LiteSpeed Engine acts as a driver and the configuration tool allows you to define a variety of configuration profiles based on file extension and from that point onwards you can use the Management Studio to setup backup jobs, maintenance plans, etc. and all you have to do is specify the file extension of the profile you wish to use.

The configuration tool allows you specify the compression level from 1 to 8, encryption level including various bit-length versions of RC2, RC4, 3DES and AES though as you’ll see later the overhead of adding the highest level (256-bit AES) isn’t that great so I’d always shoot for the maximum.
Benchmark Structure
The test is relatively unscientific since I used only one database but it was carried out systematically, the data comes from a transactional billing system which I chose as it has a mix of strucured tables and raw transactions and comes in at about 6.5GB so it wouldn’t take too long to test. I used the following configurations…

Benchmark Results
On my test database the baseline SQL Server native compression reduced the 6.2GB database to 765MB (12.2% of the original size) and took less than half the time (43%), to achieve the same level of compression using LiteSpeed I had to use Level 2 which gave me 12.2% of the original size and 40% of the original duration.
At first this doesn’t look great for the third-party tool but the benefit of using a mature backup compression engine is the flexibility and LiteSpeed’s configurations allow you to tweak the performance to solve whatever problem you have in your environment whether that be the absolute size of the backup, the backup window time or a mixture of the two.
If it’s size you’re after then Level 8 really did seem to work wonders on my test DB bringing the size down to 5.6% of the original at only 352MB though it did take 2.6 times the original duration, if it’s the backup window you’re looking to reduce then the basic Level 1 did manage to improve on the native compression by taking 0nly 37% of the original duration whilst still compressing to 13% of the original size. If like most people you’re looking to have your cake and eat it (i.e. reducing size and backup window) I’d suggest that Level 3 is the best compromise giving 10.9% of the original size at 77% of the original duration so you get some benefit in both areas, though Level 4 takes compression a bit further and still gave a slight time reduction.
Clearly, the real answer is testing and since I’m at the beginning of data warehousing project I’m not in the position to make any firm decisions but I think that even if you don’t run out and purchase it now LiteSpeed is a very valuable tool to have in your mental arsenal so that if you come up against backup size/window issues or you’re faced with older versions of SQL Server you’ve got a solution in mind already. Quest have an odd policy of keeping pricing quite opaque but I believe that the full Enterprise version (including the LiteSpeed Engine) retails for around £1,800 ($2,800) which isn’t too bad if you need that level of flexibility.
SQL Server Native Compression
| Compression | Size (MB) | Time (s) | Size (%) | Time (%) |
|---|---|---|---|---|
| Disabled | 6,261 | 70 | 100% | 100% |
| Enabled | 765 | 30 | 12.2% | 43% |
LiteSpeed Compression (No Encryption)
| Compression | Size (MB) | Time (s) | Size (%) | Time (%) |
|---|---|---|---|---|
| None | 6,262 | 70 | 100% | 100% |
| Level 1 | 813 | 26 | 13.0% | 37% |
| Level 2 | 761 | 28 | 12.2% | 40% |
| Level 3 | 680 | 54 | 10.9% | 77% |
| Level 4 | 649 | 61 | 10.4% | 87% |
| Level 5 | 596 | 122 | 9.5% | 174% |
| Level 6 | 586 | 151 | 9.4% | 216% |
| Level 7 | 387 | 178 | 6.2% | 254% |
| Level 8 | 352 | 185 | 5.6% | 264% |
LiteSpeed Compression (With Encryption)
| Compression | Size (MB) | Time (s) | Size (%) | Time (%) |
|---|---|---|---|---|
| Level 1 | 813 | 46 | 13.0% | 66% |
| Level 2 | 761 | 31 | 12.2% | 44% |
| Level 3 | 680 | 60 | 10.9% | 86% |
| Level 4 | 649 | 67 | 10.4% | 96% |
| Level 5 | 596 | 126 | 9.5% | 180% |
| Level 6 | 586 | 156 | 9.4% | 223% |
| Level 7 | 387 | 182 | 6.2% | 260% |
| Level 8 | 352 | 190 | 5.6% | 271% |
Categories: DBA, Microsoft SQL Server, Tools & Utilities Tags: 2008 R2, backup, compression, encryption, litespeed, quest, SQL Server, SQL Server 2008 R2
SQLBits 7 – Friday Conference Rundown
Many people only attend the free ‘Community Day’ of SQLBits and I can understand why given the cost (£125) for the Friday sessions but if SQL Server is how you make your living I really do think it’s worth the money. It’s not even that the Friday sessions are significantly different in content, it’s really just more of the same high level of quality you get on Saturday but when it comes to SQLBits more is definitely better.
It’s always a tough choice picking which sessions to attend so it’s often best to go with speakers you know will be good so despite having spent the entire previous day with Maciej Pilecki in the SQLBits Training Day I made my first session Maciej’s SQL Server Statistics talk. Despite a few initial technical gremlins the talk went well and gave a few insights into how statistics are used by the query optimiser with the key takeaways being to always keep both AUTO_CREATE_STATISTICS and AUTO_UPDATE_STATISTICS turned on, to consider turning on AUTO_UPDATE_STATISTICS_ASYNC (does not force queries to wait for stats to be updated but subsequent queries will benefit) and to run sp_updatestats after any major updats or to reindex your tables periodically.
My next session was Brent Ozar‘s Virtualisation and SAN talk, this gave me a whole load of questions to go back to my SAN Administrator with as well as a whole load of tests I intend to perform before I deploy my next Data Warehouse on a Hyper-V guest. One concept that was completely new to me was the Balloon Driver that hypervisors use to encourage Windows to free-up RAM, since SQL Server is a good citizen it can end-up flushing the entire Buffer Pool and wrecking your performance – the solution is to ensure that Dynamic Memory is disabled in the Hyper-V Manager. Some great related resources can be found at…
The lunchtime sponsor talk I chose was the one from Quest that covered IT Horror Stories, it was a brilliant session with plenty of audience interaction and steered clear of pimping any specific Quest products but instead just showed that the people that work there are experienced, pragmatic and generally just nice guys. I think this approach is far better than the extended product demos that many software companies tend to give as their lunchtime sessions as they’ll only be of interest if you’re genuinely considering the product and if you’re not they’ll do little to increase brand awareness with a room full of bored people on Twitter of Facebook.
After lunch I went for Buck Woody‘s talk on Business Continuity which provided a few simple paths and the crucial tasks to help get people started on a business-relevant disaster recovery strategy. I was particularly impressed with one of the central themes of the talk which was (I’m reading between the lines a little) that even if you think it’s ‘not your job’ to put a DR plan in place, it’s likely that as the company’s ‘Data Professional’ people will still look to you in times of failure and if you’ve already done all of the planning you’ll be the guy with a calm head solving the problem and if you’re not that guy – start getting your CV ready. Despite having heard the name and having read a few of his blog posts over the years I’d never heard Buck speak and he’s great so if you get the chance to see him you definitely should.
Well that wraps-up the day nicely, I’ll be posting Saturday’s round up soon after I’ve written it!
Categories: DBA, Events, Microsoft SQL Server Tags: Brent Ozar, Buck Woody, Business Continuity, Disaster Recovery, DR, Hyper-V, Microsoft SQL Server, SAN, SQL Server, SQLBits, Virtualisation, Virtualization


