Tuesday, November 22, 2011
Doccolabs.com is up!
There are various great news coming in today!
First, We're happy to announce that www.doccolabs.com is up and running.
Second, We're launching two new products (currently @ beta stages)
These products are the kickoff launch of our new path of extending our offered solutions.
So, what are those new products, you ask?
ClipTable --
A brand new way to import any data into SQL tables.
If you find yourself dealing with various SSMS wizards, trying to import those tricky Excel/CSV and other input files - ClipTable may be the best solution for you!
Out smart parsing engine reads any data you copy into your clipboard, and creates a table out of it.
Give it a shot - the beta is totally free!
http://www.doccolabs.com/products.html#ClipTable
Database File Explorer --
Our production databases usually have many files and filegroups.
Analyzing the locations, space consumption, hard-disk usage and more is usually a difficult task.
Out of the box Management Studio (SSMS) view is just a simple, unsorted, list of all files and filegroups.
So we usually find ourselves building various sys.* queries, into Excel and analyzing from there.
Well, no more!
We've created the perfect tool for such scenario, that gives you an extremely easy interface which helps you quickly understands the drive-space-file map each database is using.
Again, the beta is totally free, you're invited to give it a shot.
http://www.doccolabs.com/products.html#DatabaseFileExplorer
Enjoy!
Tuesday, September 6, 2011
Continuous Integration on SQL Server
Yesterday, I
gave a presentation at the “Israeli SQL Server User Group”
(Part of PASS), discussing the importance of continuous integration, automatic
build, and the approach of SQL Code handling in general.
Lecturing
there was a pleasure, the audience was great and I’ve got many responses during,
and after the presentation.
Presentation
aside; what puzzles me the most, is the fact that many SQL Developers don’t
treat their code the way other developers (c#, java etc...) do
SQL Code is
not just ad-hoc scripts; the code is often part of a big enterprise system -
It has to
connect altogether, to compile & build, to use the right references and to
be clean and readable.
Keeping
these guidelines, even before you implement Automatic builds / CI, help you be
in control when a team of SQL developers rapidly write new code and modify
existing one.
Another
thing worth mentioning is – Automatic deployment in Visual Studio is by all
means, not intended for production deployment.
The main
concept is to keep an updated, high-quality development (and maybe QA)
environments with the latest code. This will help us:
- Provide a ‘Latest’ database version for integration with the other dev teams
- Ensure code quality and stability
For
production, use whatever you like (diff scripts, 3rd parties…)
![]() |
| "Bad Code" |
So, there
are many solutions out there. I’ve used Unified Remote (for Android) along with
the server-side installation
Control can
be done either through Wi-Fi or BT
get it here:
Tuesday, August 30, 2011
SQL Code refactoring
Code refactoring (wiki: "disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior") is a very common method of self-improving our existing code.
Doing this is extremely important and there are many resources, articles and forums discussing this topic.
Our SQL Code (procedures, functions etc…) is no different than any other regular code
And yet, we don’t see this common practice popular enough among SQL Developers.
It is important to distinct between query refactoring, which would usually aim at reformatting the query to better readability and in some cases – better performance, and actual code refactoring.
Frequently refactoring your code helps you make sure you (and other developers in your team) don’t get lost in long, spaghetti, unstructured code as your project grows.
In addition, you’ll be surprise of how much potential bugs you may find, fix and prevent during this process.
So, here are the common items you should be aiming towards:
- Renaming (at least the internals that are not exposed to the outside application)
o There are many tools, including Visual Studio, which will help you detect any rename any references to the renamed object. I strongly advise to use those
- Keeping your procedures and functions small.
o I personally saw too many of those 1000+ lines procedures. This is always a bad practice
o And by the way, the solution is not to split a long procedure into [n] pieces J
- Keeping the same structure/pattern. I’m referring to formatting, variable declaration, naming convention and more
- Using schema prefix for different DALs. (this is a trick we’re using to divide the code into sub-systems) For example:
o Common.BatchDelete()
o CallsDAL.StartTraceCall()
o Etc…
Last but not least – during and after refactoring, always make sure that your project:
- Compiles and builds with no errors
- Deploys successfully
- Passes all relevant unit-tests (to make sure backward compatibility and logic are not harmed)
This is another big topic which I’ll cover in the near future.
Friday, October 1, 2010
Win a free copy of SQL Stripes on SQL Server Quiz 2010!
We are proud to be one of the prize sponsors for a great event: Beyond Relational's SQL Server Quiz 2010!
This major TSQL challenge will take place during This month (October)
One of the winners will win a SQL Stripes Enterprise license!
For more details - visit this link:
http://beyondrelational.com/quiz/sqlserver/general/2010/default.aspx
This major TSQL challenge will take place during This month (October)
One of the winners will win a SQL Stripes Enterprise license!
For more details - visit this link:
http://beyondrelational.com/quiz/sqlserver/general/2010/default.aspx
Wednesday, May 19, 2010
SQL Stripes 2010 is out!
We have some exciting news - SQL Stripes 2010 is officially out!
The beta phase is over, we've fixed all known bugs, added some new features and tweaks and ready to go.
SQL Stripes is now, more than ever, a complete solution for being in control over multiple SQL Servers.
The monitoring capabilities are stronger, the quick analysis options are more robust and the notifications are easy to understand.
Well, what are you waiting for? go grab the new version @ www.sqlstripes.com
For currently registered users - this upgrade is FOR FREE!
For new users - we've extended the trial period to 30 days. Which means you'll have one month to play with the stripes. There are NO LIMITATIONS whatsoever to the trial version.
I'd like to thank all people who contributed to this version, helping out test the various beta versions and suggesting new features.
On our side - the work never stops, we're already started working on the next version, as well as a set of new and exciting products which will be introduced in the near future!
Cheers,
Adi
The beta phase is over, we've fixed all known bugs, added some new features and tweaks and ready to go.
SQL Stripes is now, more than ever, a complete solution for being in control over multiple SQL Servers.
The monitoring capabilities are stronger, the quick analysis options are more robust and the notifications are easy to understand.
Well, what are you waiting for? go grab the new version @ www.sqlstripes.com
For currently registered users - this upgrade is FOR FREE!
For new users - we've extended the trial period to 30 days. Which means you'll have one month to play with the stripes. There are NO LIMITATIONS whatsoever to the trial version.
I'd like to thank all people who contributed to this version, helping out test the various beta versions and suggesting new features.
On our side - the work never stops, we're already started working on the next version, as well as a set of new and exciting products which will be introduced in the near future!
Cheers,
Adi
Tuesday, March 2, 2010
Using GUID (Unique Identifiers) as table main keys
Using What?!
Unique Identifier (which from now on will be referred to as ‘guid’) is an algorithm-based 32-byte hex string (128 bit integer) which is supposed to generate completely unique values.
I’d like to compare the chances of two identical generated guids to the chance earth will be destroyed by a meteor in the next five minutes. Now if that happens – you won’t be here to prove me wrong! J
Anyway, here’s one: 5B5D6F63-1FF0-4574-9B77-BD77D716FD66. It is probably unique and there’s no other like it in the world. (See more here - http://en.wikipedia.org/wiki/Globally_Unique_Identifier)
With today’s increasing demand for fully-distributed systems, GUID usage is increasing accordingly, as it allows managing two disconnected databases which later on needs to merge, knowing that each row on desired shared tables is unique.
Here’s a simple example –
Consider a very large company with many branches across the world.
Each branch has local users, and there’s a sync process which merges the entire users list.
Each branch has local users, and there’s a sync process which merges the entire users list.
The ‘traditional’ way is to maintain a range of numbers for each branch, use some prefix on the username to maintain uniqueness, or just make a combined key of UserId+Another column contains the branch id.
This is a classic sample for using GUID instead – make the UserId column guid and problem is solved.
This is a classic sample for using GUID instead – make the UserId column guid and problem is solved.
Sounds like fun! Any reason why I shouldn’t use it?
Well, yes. Before you get all excited and change your “int’s” and “bigint’s” to guid, consider the following:
- Guid column takes 16 bytes, which is double than Bigint. This means that index on the column will also take more space
- Index Fragmentation is an issue and it is most likely to happen.
(See more about it on the Tips section below)
(See more about it on the Tips section below)
Some Best-Practices Tips:
[Tip #1]
The first, and probably the most important tip is to avoid using CLUSTERED INDEX on guids.
This is because the guid values are random – a physical sort will cause the table to be sorted on every insert.
Still, in many cases you’d want to avoid having HEAP tables, which means another ID (probably an internal identity) has to be used.
This is because the guid values are random – a physical sort will cause the table to be sorted on every insert.
Still, in many cases you’d want to avoid having HEAP tables, which means another ID (probably an internal identity) has to be used.
When possible - use the NEWSEQUENTIALID function. This will create unique guids on a table but will make sure the new generated guid is greater than the last. (It is still globally unique as long as the machine has its own MAC address).
Let’s see a quick sample of the differences between the NEWID() function and the NEWSEQUENTIALID default value:
Let’s create two tables; each uses one of the techniques:
-- Creating two tables:
IF OBJECT_ID('UsersNewId') IS NULL
BEGIN
CREATE TABLE UsersNewId
(
UserId UNIQUEIDENTIFIER PRIMARY KEY NONCLUSTERED DEFAULT NEWID(),
UserName VarChar(255)
)
END
IF OBJECT_ID('UsersNewSeqId') IS NULL
BEGIN
CREATE TABLE UsersNewSeqId
(
UserId UNIQUEIDENTIFIER PRIMARY KEY NONCLUSTERED DEFAULT NEWSEQUENTIALID(),
UserName VarChar(255)
)
END;
-- Now, let's fill the tables with some data
-- Note: I'm using SQL2008+ syntax here; On SQL2005 separate the insert statements
INSERT INTO UsersNewId(UserName) VALUES ('User1'),('User2'),('User3'),('User4'),('User5')
INSERT INTO UsersNewSeqId(UserName) VALUES ('User1'),('User2'),('User3'),('User4'),('User5')
-- Now, let's see the tables
SELECT * FROM UsersNewId
SELECT * FROM UsersNewSeqId
The results:
Note the guid on the 2nd table looks the same on first sight, but actually it is not. Those are increasing values that still maintain uniqueness.
This is obviously much better for index fragmentation of any time!
[Tip #2]
Related to the above tip – as a DBA, try to keep the guid generation on your side! othewise
If the guid’s are generated by a different layer in your application (DAL or so), the guids cannot be sequential.
If the guid’s are generated by a different layer in your application (DAL or so), the guids cannot be sequential.
Besides, try to think as if the guid’s are actually a new version of your INT identities; You wouldn’t let anyone control the auto-increase now would you?
This is practically the same.
This is practically the same.
In some cases you may want to consider surrogate keys, which will be used as the foreign key between the tables. To use the sample at the beginning of this article – each user will have its own GUID, but with an additional “UserInternalId” column (int) which will be the one to connect the main table to all the rest.
[Tip #4]
Don’t use Guid if you don’t have to! When a table needs an ID which does not have to be unique across the enterprise, keep using the regular numeric id.
Final Words:
Guids are great and simple solution to maintain uniqueness across the enterprise. However, don’t overuse it when not required as it might hurt your databases performances.
This is a very wide subject. I was trying to limit myself to a blog-post size; I might write a follow-up article about this subject
Thursday, February 11, 2010
Off-Topic: Few words about Google Buzz
I've posted a short article about the new (as for today) Google Buzz.
Read more here: http://adisapir.blogspot.com/2010/02/buzz-yay-or-nay.html
Oh, and a quick Stripes update - the non-beta version is near. Except some news soon!
Cheers
Read more here: http://adisapir.blogspot.com/2010/02/buzz-yay-or-nay.html
Oh, and a quick Stripes update - the non-beta version is near. Except some news soon!
Cheers
Subscribe to:
Posts (Atom)



