FW: Quick and Dirty : Vimdiff Tutorial

From  :

I recently started using exclusively Vim (and gVim) for my coding needs. Vimdiff is a tool that comes bundled with Vim and its a wonderful tool for comparing code and merging changes. If you’d prefer to use a non-Vim based diff tool, checkout visual diff tools in linux for more variety.  read morevimdiff

Using VIM, even on Microsoft Windows, for comparing two text files is very very simple and easy to do.  Definitely go check out Amjith’s post for the keyboard short cuts!

Share Button

HowTo: Comparing two tables and returning the # of rows that match FAST

The most intuitive way to write a comparison of two tables and spit out the # of rows that are the same involves a left join:

select 'Investment' as TableName, count(*) as RowCount
from Investment_A a, Investment_B b
where
  a.col1 = b.col1
  AND a.col2 = b.col2
  AND a.col3 = b.col3
  AND a.col4 = b.col4

This returns the correct answer but is very slow. Is there a better way? Of course!

select 'Investment' as TableName, count(*) as RowCount
from
(
   select 1 as num
   FROM (
      select * from Investment_A
      UNION ALL
      select * from Investment_B
   ) tmp
   GROUP BY col1, col2, col3, col4
   HAVING COUNT(*) > 1
) tmp2

By pushing the comparison off into the GROUP BY, we leverage the DBMS engine far more efficiently. There are two drawbacks:

  1. Readability of the SQL code
  2. Far more temporary storage is used for the GROUP BY. There is a real risk of running out of temporary storage if the tables are large.
Share Button

FW: WordPress vs. Drupal: Not that it’s about winning

Selena over at Tending the Garden, posted a very good video of why you would choose WordPress or Drupal. It seems a little slanted towards Drupal but that may just be me 😉

Share Button