Could you pass the Cognitive Reflection Test?

I am reading the book David and Goliath: Underdogs, Misfits, and the Art of Battling Giants by Malcolm Gladwell and I found the following test in this book. The test is the Cognitive Reflection Test (CRT). It was invented by Yale professor Shane Frederick.

A bat and a ball cost $1.10 in total. 
The bat costs $1.00 more than the ball. 
How much does the ball cost?

And here is another one

It takes 5 machines 5 minutes to make 5 widgets, 
how long would it take 100 machines to make 100 widgets?


Leave the answer in the comments

INSERT INTO vs SELECT INTO... Different Execution plan

Take a look at these two queries


INTO #SomeTempTable 
FROM dbo.SomeTable po 
WHERE po.SomeID = @SomeId
AND @Date BETWEEN po.SomeDate AND po.SomeOtherDate 
AND EXISTS (SELECT 1 FROM dbo.OtherTbl pe 
JOIN @TableVar ro ON pe.ID = ro.Id 
WHERE pe.ID = po.ID)

INSERT INTO #SomeTempTable 
FROM dbo.SomeTable po 
WHERE po.SomeID = @SomeId
AND @Date BETWEEN po.SomeDate AND po.SomeOtherDate 
AND EXISTS (SELECT 1 FROM dbo.OtherTbl pe 
JOIN @TableVar ro ON pe.ID = ro.Id 
WHERE pe.ID = po.ID)

The queries are pretty much identical except that the top query used SELECT INTO while the bottom query uses INSERT INTO SELECT

The top query runs for 3 seconds while the bottom query runs instantly

Now look at the plans I grabbed with Plan Explorer, I scrubbed out the real table names. Here is the INSERT INTO SELECT plan


Here is the SELECT INTO plan


See that, a completely different plan. What do you think caused this?

Bitcoin Center NYC, wondering how long that will stay open

There is a Bitcoin Center in New York City, it is located at 40 Broad Street. I passed this location many times but somehow missed that this was a Bitcoin Center. I wonder how long it will stay open after all the trouble that Bitcoin has been having lately.  MtGox is pretty much shutdown right now. Here are the two statements that they released

Dear MtGox Customers,

As there is a lot of speculation regarding MtGox and its future, I would like to use this opportunity to reassure everyone that I am still in Japan, and working very hard with the support of different parties to find a solution to our recent issues.

Furthermore I would like to kindly ask that people refrain from asking questions to our staff: they have been instructed not to give any response or information. Please visit this page for further announcements and updates.

Mark Karpeles

Dear MtGox Customers,

In light of recent news reports and the potential repercussions on MtGox's operations and the market, a decision was taken to close all transactions for the time being in order to protect the site and our users. We will be closely monitoring the situation and will react accordingly.

Best regards,
MtGox Team


Anyway here is a short video of the Bitcoin Center in New York City

Euro 2016 groups draw


The draw for Euro 2016 in France has finished. The top two teams in each group will automatically quality. The best third-placed finisher will automatically quality as well. The remaining eight third-placed teams will face on in play-offs in November 2015.

Here is what the groups look like

Group A
Czech Republic

Group B
Bosnia and Herzegovina

Group C
FYRO Macedonia

Group D

Group E
San Marino

Group F
Northern Ireland
Faroe Islands

Group G

Group H

Group I

Mix Korn, Rage Against the Machine, Sepultura and Pantera and you get Maximum the Hormone

If you were to dump Korn, Rage Against the Machine, Sepultura and Pantera in a blender, what you would get is Maximum the Hormone.  Maximum the Hormone (マキシマムザホルモン ) is a Japanese nu metal/hardcore punk band from Hachiōji, Tokyo


Make sure to listen to the whole song and let me know what you think, enjoy!

Review of SQL Performance Explained by Markus Winand


SQL Performance Explained is a database book written by Markus Winand, the book is a little less than 200 pages. The book covers Oracle, MySQL, PostgreSQL and SQL Server. The terminology used in the book is that of the Oracle RDBMS but there are site notes for the other RDBMS products. The primary focus of this book is indexing, if you are interested in indexing then this book is for you, the one index this book covers in the B-tree Index, other indexes are not covered in this book at all.


There are 8 chapters in this book and an appendix, here is what is in the book.

CHAPTER 1 - Anatomy of an Index
The first chapter is the only one that doesn't cover SQL specifically; it is about the fundamental structure of an index. An understanding of the index structure is essential to following the later chapters — don’t skip this!
Although the chapter is rather short — only about eight pages — after working through the chapter you will already understand the phenomenon of slow indexes.

CHAPTER 2 - The Where Clause
This is where we pull out all the stops. This chapter explains all aspects of the where clause, from very simple single column lookups to complex clauses for ranges and special cases such as LIKE. This chapter makes up the main body of the book. Once you learn to
use these techniques, you will write much faster SQL.

CHAPTER 3 - Performance and Scalability
This chapter is a little digression about performance measurements and database scalability. See why adding hardware is not the best solution to slow queries.

CHAPTER 4 - The Join Operation
Back to SQL: here you will find an explanation of how to use indexes to perform a fast table join.

CHAPTER 5 - Clustering Data
Have you ever wondered if there is any difference between selecting a single column or all columns? Here is the answer — along with a trick to get even better performance.

CHAPTER 6 - Sorting and Grouping
Even order by and group by can use indexes.

CHAPTER 7 - Partial Results
This chapter explains how to benefit from a “pipelined” execution if you don’t need the full result set.

CHAPTER 8 - Insert, Delete and Update
How do indexes affect write performance? Indexes don’t come for free — use them wisely!

APPENDIX A - Execution Plans
Asking the database how it executes a statement.

So who is this book for? This book is primarily for developers, if you are an admin and you want to know about how indexing work, then this book will help you understand that. Don't expect to find how to reorganize or rebuild indexes, that is not the focus of this book.

I enjoyed this book a lot, there is a ton of useful information for developers and as a developer you should understand how data is stored and how you can get to the data more efficiently. Once you are done with this book, you will understand databases and retrieval of data much better and you might even rethink how you are storing some of the data. I also like the fact that this book is a little less than 200 pages and focused one one thing instead of those monster 1000+ page books that cover dozens of topics but don't delve deep into any of those topics.

I give this book two thumbs up because it does what the author's intentions, is focused on indexing and explains it well. I do have one little bone to pick with the book and that is that the book does not mention the XML Execution plan that was introduced with SQL Server 2005.


You can check out the book at the book's website here:

You can also check Amazon here: SQL Performance Explained


So wrong but so brilliant


Someone bought a gift card, then this person made stickers of the bar code from his card. Then the person used this stickers to place over the bar codes of the cards in the store. Someone buys someone a gift card in the store and what they have funded is the card from the person who placed the sticker.

Whoever came up with this is a genius, morally it is very wrong of course.  I would be pissed if I gifted someone a card and it turned out to be empty