SQL Server – Difference Between UNION And UNION ALL

I am trying to recall some of the interview questions that I was being asked during my job hunting and would like to share some studies or findings which I read from the experts regarding these questions. The first one that I remember is the differences between UNION and UNION ALL.

I believe in many cases we do use both of these commands in our queries. And, what are their differences and in term of performance which one is better?

UNION command is used in the queries to select data from two or more tables similarly to JOIN command, except UNION command selected columns need to be same data types and same number of columns to be selected. It returns the distinct data of both tables. It does the SELECT DISTINCT on the results set.

UNION ALL command is same as the UNION command except it returns all the data from the selected tables. In other words, UNION ALL includes duplicated rows.

However, the UNION ALL gives the faster results when we execute the queries. You can check it from the execution plan to compare both. Reason is UNION command will do the filtering during the execution. If you are sure that your return results are unique, it would be a good idea to use UNION ALL for better performance.

Advertisements

SQL Server – Difference Between DATETIME and DATETIME2

I came across the article written by Pinal Dave about the difference between DATETIME and DATETIME2. In my years working as a database administrator, I did use DATETIME most of the time for database structure design. So far, I did not use the data type DATETIME2 before.

It becomes more interesting when he shared with us the problems when using DATETIME2 and SYSDATETIME(). In a short summary he commented as below:-

The best way is to use GETDATE() if you are using DATETIME, and SYSDATETIME() if you are using DATETIME2 to populate them with current date and time for accurately addressing the precision. As DATETIME2 is introduced in SQL Server 2008, the above script will only work with SQL Server 2008 and later versions.

Read Pinal Dave full article, https://blog.sqlauthority.com/2010/06/11/sql-server-difference-between-datetime-and-datetime2/

Old Chang Kee

Old Chang Kee, Chicken Porridge.

When it comes to the old label, Old Chang Kee, many of us surely tried all their fried food especially their curry puff. I like their curry puff too, occasionally we will order it for party or any other occasions. Also, I love the Old Change Kee, chicken porridge with the yau tiao. It is a breakfast set and always sold-out early.

The porridge is well tasted but I feel it would be better if they can adjust the amount of the white pepper in the porridge or put it as an option for people to add it if they want to at the counter.

The hot porridge mixes well with sesame oils and white pepper and eat it with the yau tiao, a Chinese fried dough, as you can see the long fried stick on top of my porridge. Dip the yau tiao into the porridge and it will become soften, easy and delicious when you bite it. It is a filling porridge or breakfast meal which it worthy to buy for breakfast and you can have late lunch.

Black Pot Noodle

Black Pot Noodle at Tampines Mall Kopitiam.
Address: Tampines Mall, 4 Tampines Central 5 #04-27/29, 529510, Singapore.

It has never been failing to satisfy my craving for a hotpot of ramen. I usually visit this Taiwanese food stall in Tampines Mall Kopitiam to have my ramen. I love their broth for the ramen and the texture of the noodle is springy type. At times, they will have promotion as well for different set of meals.

For this visit, I wanted to eat rice with the fried fish because I am getting back my appetite to eat after having a week of flu and cough. The fried fish is rather smaller this time. It comes with some vegetables and half hard-boiled egg.

When it comes to rice set, the soup is not spicy compared to the ramen in which you can ask for more spicy soup. Another difference is for rice set, they add the glass noodle into the soup and it makes me feel very full after eating them. It is one of the worth to try food in this food court.

Soup Spoon

Soup Spoon

Sunday’s afternoon lunch meet up with my great “brother” in Singapore. I met up with my friend who treated each other like brother and sister after a short chat in FB messenger whereby I told him about an IT event on-going. We met up at Raffles Place MRT where it was most convenient place for both of us to meet up, as I was coming down from the East and he was taking the Red line from the North.

Before that, I purchased the Groupon’s voucher of SGD$20.00 worth of value which we can order two sets of soups and we saved about few dollars each person. It is always good to check out the great deals online before we head off to the restaurant.

I ordered the roasted pumpkin soup with a tuna mayo bread. It is one of their set with bread. Instead of bread, you can choose to have sets with salad too. My friend chose to eat the minestrone soup with salad. The portion of our food is quite big portion which comes with bread, salad and rice. Besides that, the set meal comes with a drink of your choice too.

The pumpkin is rich source of minerals like copper, calcium, potassium and phosphorus. Pumpkin seeds indeed are an excellent source of dietary fiber and mono-unsaturated fatty acids, which are good for heart health. That day, I was still having the cough and flu. After having the pumpkin soup and hot black tea, my flu was getting better than the days before.

It is an healthy meal of the day with great set meal offer which I see its benefits more than other things.

Mook’s Thai Mookata BBQ

Mook’s Thai Mookata BBQ.
Address: 2 Liang Seah Street, Bugis, Singapore.

On one of the running nights with my friends in Singapore’s city area, we stopped by Bugis for our dinner, just a short walk from my friend’s house. We walked around the food street at Liang Seah Street where many of the restaurants are selling steamboat located and we decided to try the set meal of 4 person at the Mook’s Thai Mookata BBQ.

We were greeted at the main door and there was no crowd when we entered the restaurant at 9PM. We seated at the center of the restaurant so it was quite easily to reach the waiters for food ordering.

Then, the waiter showed us the menu and we decided to go with our initial plan of ordering the set meal. The waiter asked whether we have any of the ingredients of the set meal that we were not eating. It is kind of waste if we did not eat and still order it. Well, it was only me who did not take the pig liver so we did not change anything from the set meal and the guys wanted to have rice, we added two bowls of rice. We did not order drink. The waiting time to be served is reasonable, judging by the crowd when we were there.

The first picture of the food served on our table. It looks pretty reasonable portion of meats and vegetables, two bowls of rice and a jug of the soup broth. Nicely presented with the side background of my friend’s bag, SuperDry.

Let me show you the closed up picture of the meat.

The waiter told us to grease it first before start grilling our meat. It is not easy to work on it especially using the small tongs. After we managed to grease it well enough, we placed our meat on top and the clams, meatballs, crabmeats and sausages on the soup to start cooking.

Then, added the vegetable and we started eating. We have to occasionally grease the grill area as it easily turned brown and it would be harder to grill our meat later. Besides that, we have to add the soup broth constantly too. For this set meal, we can easily grill it for three or four rounds with all the basic ingredients that we ordered.

We can add the clams and prawn head to make the soup sweeter along with the cabbage. Lucky that this group of friends are omnivores, we ate everything that they served on the plates. Maybe, we were hungry back then.

Lastly, we put in the noodle and cooked it with the remaining soup broth. The soup is sweet and tasty, just a little oily because of the oil from the grilled meats. We almost finished the soup 🙂