As mentioned by Seth the data.table package has evolved and now proposes optimized functions for this.
To all the ones who don't want to get into the documentation, here is the fastest and most memory efficient way to do what you want :
uniqueN(a)
And if you only want to choose a subset of columns you could use the 'by' argument :
uniqueN(a,by = c('V1','V2'))
EDIT : As mentioned in the comments this will only gives the count of unique rows. To get the unique values, use unique instead :
unique(a)
And for a subset :
unique(a[c('V1',"V2")], by=c('V1','V2'))