Wednesday, 2 May 2018

Mongo DB Index creation limitations



Please consider below limitations before creating Index's in Mongo DB.

  •  A collection cannot have more than 64 indexes.
  •  Index entries cannot exceed 1024 bytes.
  •  The name of an index must not exceed 125 characters (including its namespace).
  •  In-memory sorting of data without an index is limited to 32MB. This operation is very CPU intensive, and in-memory sorts indicate an index should be created to optimize these queries.

Saturday, 24 March 2018

Recover from Git Hard Reset

Hey Guys,

Today we talk about how to recover  from git reset head command.

Sometimes we do git reset HEAD~  to move the pointer to previous commit . 

If we again we want to come back to latest commit or other commits

Do the below

git reflog show    ## display all the commits log with HEAD

git reset HEAD@{1}     ## reset to selected HEAD from above list

Monday, 20 November 2017

Mysql stored procedure to export sql insert statements

DELIMITER $$

DROP PROCEDURE IF EXISTS `InsGen` $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `InsGen`(in_db varchar(20),in_table varchar(20),in_file varchar(100))
BEGIN

declare Whrs varchar(500);
declare Sels varchar(500);
declare Inserts varchar(2000);
declare tablename varchar(20);

set tablename=in_table;

# Comma separated column names - used for Select
select group_concat(concat('concat(\'"\',','ifnull(',column_name,','''')',',\'"\')')) INTO @Sels from information_schema.columns where table_schema=in_db and table_name=tablename;

# Comma separated column names - used for Group By
select group_concat('`',column_name,'`') INTO @Whrs from information_schema.columns where table_schema=in_db and table_name=tablename;

#Main Select Statement for fetching comma separated table values
set @Inserts=concat("select concat('insert into ", in_db,".",tablename," values(',concat_ws(',',",@Sels,"),');') from ", in_db,".",tablename," group by ",@Whrs, " INTO OUTFILE '", in_file ,"'");

PREPARE Inserts FROM @Inserts;
EXECUTE Inserts;

END $$

DELIMITER ;


Ref & Credits : http://kedar.nitty-witty.com/blog/mysql-stored-procedure-to-generate-extract-insert-statement