Well, it might have been an everlasting discussion about which one of these to use, count(1) or count(*).
I guess, this article of Thomas Kyte already clarified the situation long long ago (well, for IT industry 2005 is long ago anyway, especially given the speed at which we are moving.)
Essentially, what askTom says that, count(*) is better than count(1) since count(1) translates to count(*) internally anyway. I wonder then, why would someone want to use count(1) anyway.
There is at least one more step involved in getting to the actual result. And there is another possible tweak, count(1) has to evaluate an expression as well, "count(1) where 1 is not null". Though its a tautology equivalent, it has to be evaluated nonetheless.
Further, there was some misconception about how the result is returned, whether its read from the data dictionary, this view or table or something like that. I dont think so. The result is calculated at the exact run time,when the query is run, and it actually goes ahead and counts the records in the table.
Should set the record straight...
Wednesday, July 28, 2010
Oracle Count(1) vs Count(*)
Friday, July 23, 2010
Developing a Rails application using an existing database
Initially we needed the basic CRUD screens for some tables. Being lazy (i m really proud of that), I set out finding if there a solution that generates the forms (read views) for the existing tables/models.
I have already managed to generate models/schema.rb using another gem. This is called magic_model. Read more about that here
Then google helped me find this another gem called scaffold_form_generator which generates the necessary views/forms for a given model. However, there need to be some improvements required on that (I think). perhaps I would contribute something (if I find out enough on how to do that)
Well, for the moment, I am struggling with handling of the missing special meaning column from the legacy tables. Will continue writing on this...
Wednesday, July 21, 2010
Making rails talk to SQL Server Express Edition
Make an odbc connection - pointing to the db server, preferably make a sql server authentication user
Install the following gems
- activerecord-odbc-adapter (2.0)
- activerecord-sqlserver-adapter (2.3.8)
- dbd-odbc (0.2.5)
- dbi (0.4.5)
- deprecated (2.0.1)
Further, I copied odbc.so and odbc_utf8.so files from http://www.ch-werner.de/
My database.yml file looks like this -
development:
adapter: sqlserver
mode: ODBC
dsn:
username: myUserName
password: myPassword
Friday, July 16, 2010
winscp vs cuteftp
I recently had an experience of transferring relatively larger files from a windows box to linux one.
I had some files which were ranging from 2.1 GB to 4.x GB. The company traditionally uses cuteftp to transfer (read ftp) files across servers. So I started with that anyway.
However, all my transfer attempts were failing. After transferring 2 GB of data, cuteftp would end the transfer and give away some or other error message. I figured that this was happening only to files which were larger in size. And this transfer consumed more than hour or so before it failed.
Google couldnt help a lot, so, finally i got down to winscp. And, it worked out so well. Not only the transfers didnt fail, but they finished within minutes, instead of the hours and hours spent by cuteftp.
Perhaps its some setting somewhere in cuteftp that I couldnt find, but the whole experience has left me more inclined towards the open source community.
Thanks a ton guys .. :)
Wednesday, July 14, 2010
Trying to become a Data warehousing architect... !!!
- Describe advantages of the CIF architecture versus the bus architecture with conformed dimensions. Which would fit best in our environment given [some parameters they give you] and why
- Describe snow-flaking
- Describe fact-less fact tables.
- Draw a star schema of our business
- Describe common optimization techniques applied at the data model level
- How do you handle data rejects in a warehouse architecture?
- Describe common techniques for loading from the staging area to the warehouse when you only have a small window.
- How do you load type 1 dimensions
- How do you load type 2 dimensions, and how would you load it given our [insert business particularity]
- How would you model unbalanced hierarchies
- How would you model cyclic relations
- What major elements would you include in an audit model?
- How would you implement trace-ability ?