Difference between Information_schema vs sys tables in SQL Server

Both INFORMATION_SCHEMA and sys objects are both metadata catalogs that are available in SQL Server. The INFORMATION_SCHEMA set of views are the ANSI/ISO standard catalogs for metadata. Most RDBMSs support the majority of INFORMATION_SCHEMA views, and each view exposes essentially identical information regardless of the vendor. In SQL Server, most, if not all, the INFORMATION_SCHEMA … Read more

Is SQL GROUP BY a design flaw? [closed]

You don’t have to group by the exactly the same thing you’re selecting, e.g. : SQL:select priority,count(*) from rule_class group by priority PRIORITY COUNT(*) 70 1 50 4 30 1 90 2 10 4 SQL:select decode(priority,50,’Norm’,’Odd’),count(*) from rule_class group by priority DECO COUNT(*) Odd 1 Norm 4 Odd 1 Odd 2 Odd 4 SQL:select decode(priority,50,’Norm’,’Odd’),count(*) … Read more

How to figure out if mysql index fits entirely in memory

Depends on Storage Engine MyISAM (Caches Index Pages From .MYI files) SELECT FLOOR(SUM(index_length)/POWER(1024,2)) IndexSizesMB FROM information_schema.tables WHERE engine=”MyISAM” AND table_schema NOT IN (‘information_schema’,’performance_schema’,’mysql’); Subtract that from key_buffer_size. If the answer > 0, then Yes InnoDB (Caches Data and Index Pages) SELECT FLOOR(SUM(data_length+index_length)/POWER(1024,2)) InnoDBSizeMB FROM information_schema.tables WHERE engine=”InnoDB”; Subtract that from innodb_buffer_pool_size. If the answer > … Read more

SQL Filter criteria in join criteria or where clause which is more efficient

I wouldn’t use performance as the deciding factor here – and quite honestly, I don’t think there’s any measurable performance difference between those two cases, really. I would always use case #2 – why? Because in my opinion, you should only put the actual criteria that establish the JOIN between the two tables into the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)