Related
i tryng to implements a geolocation query that search over the products (150.000) in a table that have latlng id_product and id_categories, and the query run very slow . This is the query:
$prodottip = \App\Models\Prodotti::join('products2sellers', 'products2sellers.id_prodotto', 'prodotti.product_id')->where('prodotti.id_tipologia', 'PRODUCT')->join('aziende', 'products2sellers.id_seller', 'aziende.Id')->select('prodotti.*', 'aziende.*')->whereRaw('match (prodotti.nome, prodotti.categoria_composta, prodotti.descrizione_lunga) against (? in boolean mode)', [$cosa])->selectRaw('( 6371 * acos( cos( radians(?) ) *
cos( radians( products2sellers.lat ) )
* cos( radians( products2sellers.lng ) - radians(?)
) + sin( radians(?) ) *
sin( radians( products2sellers.lat ) ) )
) AS distance', [$lat, $lng, $lat])->OrderBy('distance', 'ASC');
any suggestion to speed it UP?
This is the dump of the 3 table.
I'm on MariaDB but i have also installed MongoDB.
CREATE TABLE `aziende` (
`Id` int(11) NOT NULL,
`contatto` varchar(100) NOT NULL,
`visualizzazioni` int(11) NOT NULL DEFAULT '0',
`categoriapg` varchar(130) NOT NULL DEFAULT '',
`titolo` varchar(50) NOT NULL DEFAULT '' COMMENT 'verrĂ utilizzato come nome aziendale',
`sottotitolo` varchar(255) NOT NULL DEFAULT '' COMMENT 'slogan aziendale',
`immagine` varchar(50) NOT NULL,
`logo` varchar(50) NOT NULL,
`IndirizzoGeolocalizzato` varchar(250) NOT NULL DEFAULT '',
`email` varchar(100) NOT NULL DEFAULT '' COMMENT 'email ufficiale',
`telefono` varchar(20) NOT NULL DEFAULT '' COMMENT 'telefono ufficiale',
`sitoweb` varchar(150) NOT NULL DEFAULT '' COMMENT 'sito web ufficiale',
`visualizza` int(1) NOT NULL DEFAULT '2',
`scadenzacontratto` datetime NOT NULL,
`ultimouser` varchar(13) NOT NULL DEFAULT '',
`ragionesociale` varchar(255) NOT NULL DEFAULT '',
`piva` varchar(30) NOT NULL DEFAULT '',
`codfisc` varchar(20) NOT NULL DEFAULT '',
`agente` int(11) NOT NULL,
`Provincia` varchar(50) NOT NULL DEFAULT '0',
`Citta` varchar(250) NOT NULL DEFAULT '0',
`attiva` int(11) NOT NULL,
`id_utente` int(11) NOT NULL,
`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`entry_by` int(11) NOT NULL DEFAULT '0',
`descrizione_azienda` longtext NOT NULL,
`tag_title` varchar(100) NOT NULL,
`tag_description` varchar(100) NOT NULL,
`keywords` varchar(100) NOT NULL,
`coupon` varchar(20) NOT NULL,
`sconto` int(11) NOT NULL,
`partner` int(11) NOT NULL,
`lat` double NOT NULL,
`long` double NOT NULL,
`regione` varchar(30) NOT NULL,
`nazione` varchar(30) NOT NULL,
`via` varchar(100) NOT NULL,
`cap` varchar(10) NOT NULL,
`condizioni_vendita` longtext NOT NULL,
`condizioni_spedizione` longtext NOT NULL,
`cellulare` varchar(50) NOT NULL,
`id_piano` int(11) NOT NULL,
`citta_fatturazione` varchar(300) NOT NULL,
`via_fatturazione` varchar(300) NOT NULL,
`civico_fatturazione` varchar(20) NOT NULL,
`stato_fatturazione` varchar(30) NOT NULL,
`cap_fatturazione` int(10) NOT NULL,
`provincia_fatturazione` varchar(20) NOT NULL,
`regione_fatturazione` varchar(10) NOT NULL,
`lat_fatturazione` double NOT NULL,
`long_fatturazione` double NOT NULL,
`indirizzo_fatturazione` varchar(300) NOT NULL,
`categoria` int(11) NOT NULL,
`numero_civico_fatturazione` varchar(20) NOT NULL,
`numero_civico` varchar(12) NOT NULL,
`sla1` float NOT NULL,
`sla2` float NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='aziende promotrici';
-- --------------------------------------------------------
--
-- Struttura della tabella `prodotti`
--
CREATE TABLE `prodotti` (
`id` int(11) NOT NULL,
`id_tipologia` varchar(50) NOT NULL,
`categoria_principale` varchar(110) DEFAULT NULL,
`nome` varchar(50) DEFAULT NULL,
`immagini` varchar(1000) DEFAULT NULL,
`entry_by` int(11) NOT NULL,
`id_produttore` varchar(255) DEFAULT NULL,
`id_unita_misura` int(11) NOT NULL,
`prezzo` float DEFAULT NULL,
`link_statico` varchar(100) DEFAULT NULL,
`attivo` int(11) NOT NULL,
`numero_visualizzazioni` int(11) NOT NULL,
`quantita_magazzino` int(11) DEFAULT NULL,
`backorders` int(11) NOT NULL,
`codice_sku` varchar(10) DEFAULT NULL,
`pagamenti_abilitati` varchar(50) NOT NULL,
`spedizioni_abilitate` varchar(50) NOT NULL,
`tags` text NOT NULL,
`tag_title` text NOT NULL,
`tag_keywords` text NOT NULL,
`tag_description` text NOT NULL,
`id_gruppi_utenti` varchar(10) NOT NULL,
`vetrina_on` int(11) NOT NULL,
`numero_acquisti` int(11) DEFAULT '0',
`thumbnail` varchar(500) NOT NULL,
`quantita_minima` int(11) DEFAULT NULL,
`id_tasse` int(11) NOT NULL,
`descrizione_breve` longtext,
`descrizione_lunga` longtext,
`negozio` varchar(50) DEFAULT NULL,
`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`prezzo_scontato` float DEFAULT NULL,
`alternativi` varchar(200) NOT NULL,
`immagine_principale` varchar(100) DEFAULT NULL,
`rating` float DEFAULT NULL,
`sottocategoria` varchar(500) DEFAULT NULL,
`cod_abbonamento` int(11) NOT NULL,
`numero_acquisto` int(11) NOT NULL,
`featured` int(11) NOT NULL,
`bicolors` varchar(255) DEFAULT NULL,
`genere` varchar(250) DEFAULT NULL,
`model_id` varchar(110) DEFAULT NULL,
`barcode` int(11) DEFAULT NULL,
`prezzo_acquisto` double DEFAULT NULL,
`univoco` varchar(12) DEFAULT NULL,
`color` varchar(255) DEFAULT NULL,
`season` varchar(255) DEFAULT NULL,
`product_id` int(11) NOT NULL,
`slug` varchar(500) NOT NULL,
`showcase` int(11) NOT NULL,
`optimized` int(11) DEFAULT NULL,
`materiale` varchar(300) NOT NULL,
`peso` float NOT NULL,
`model_qty` int(11) NOT NULL,
`fornitore` varchar(100) NOT NULL,
`madein` varchar(100) NOT NULL,
`id_categoria` int(11) NOT NULL,
`categoria_composta` varchar(250) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Struttura della tabella `products2sellers`
--
CREATE TABLE `products2sellers` (
`id` int(11) NOT NULL,
`id_prodotto` int(11) NOT NULL,
`id_seller` int(11) NOT NULL,
`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`taglia` varchar(300) DEFAULT NULL,
`colore` varchar(200) DEFAULT NULL,
`model_id` varchar(50) DEFAULT NULL,
`qty` int(11) DEFAULT NULL,
`lat` double NOT NULL,
`lng` double NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Indici per le tabelle scaricate
--
--
-- Indici per le tabelle `aziende`
--
ALTER TABLE `aziende`
ADD PRIMARY KEY (`Id`);
--
-- Indici per le tabelle `prodotti`
--
ALTER TABLE `prodotti`
ADD PRIMARY KEY (`id`);
--
-- Indici per le tabelle `products2sellers`
--
ALTER TABLE `products2sellers`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT per le tabelle scaricate
--
--
-- AUTO_INCREMENT per la tabella `prodotti`
--
ALTER TABLE `prodotti`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=52102;
--
-- AUTO_INCREMENT per la tabella `products2sellers`
--
ALTER TABLE `products2sellers`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=52101;COMMIT;
Basically i can structure this as well using eager loading but i suppose that the results is the same. Also i can try to use some geolocation/plugin in MariaDB but i need some suggestion
"Find nearest" has 3 speeds:
Painfully slow due to computing the distance to every item and finding the closest.
Possibly OK -- using a "bounding box" and a suitable index.
Fast -- but the code is complex.
More discussion: http://mysql.rjweb.org/doc.php/find_nearest_in_mysql
The solution must be coded at the MySQL/MariaDB level. Laravel may need to use raw SQL to get at it.
(It won't answer the Question, but do use InnoDB, not MyISAM.)
CREATE TABLE IF NOT EXISTs `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(255) NOT NULL,
`firs_name` varchar(255) NOT NULL,
`last_name` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`password` varchar(32) NOT NULL,
`sign_up_date` date (255) NOT NULL,
`activated` enum('0','1') NOT NULL,
PRIMARY KEY `id`
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
Problem is here: sign_up_date date (255) NOT NULL
When you refer to date you don't set the maximum of characters.
Try: sign_up_date date NOT NULL
Try with the below code
CREATE TABLE IF NOT EXISTs `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(255) NOT NULL,
`firs_name` varchar(255) NOT NULL,
`last_name` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`password` varchar(32) NOT NULL,
`sign_up_date` date NOT NULL,
`activated` enum('0','1') NOT NULL,
PRIMARY KEY `id`
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
Created these two tables successfully
First table
CREATE TABLE IF NOT EXISTS `lawncare_user` (
`ID` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`FirstName` varchar(255) NOT NULL,
`LastName` varchar(255) NOT NULL,
`Email` varchar(255) NOT NULL,
`UserType` varchar(30) NOT NULL,
`UserName` varchar(255) NOT NULL,
`Password` varchar(255) NOT NULL,
`AddedBy` int(11) NOT NULL,
`AddedOn` date NOT NULL,
`ModifiedOn` date DEFAULT NULL,
`Status` BOOLEAN NOT NULL DEFAULT '0',
`QuestionID` int(11) DEFAULT NULL,
`QuestionAnswer` text DEFAULT NULL,
`Params` text NOT NULL,
`Address` text NOT NULL,
`Country` varchar(300) NOT NULL,
`State` varchar(300) NOT NULL,
`City` varchar(300) NOT NULL,
`ContactNo` double DEFAULT NULL,
`Activation` BOOLEAN NOT NULL DEFAULT '0',
`ActivatedOn` date DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Second table
CREATE TABLE IF NOT EXISTS `lawncare_customer` (
`ID` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`FirstName` varchar(255) NOT NULL,
`LastName` varchar(255) NOT NULL,
`Email` varchar(255) NOT NULL,
`Password` varchar(255) NOT NULL,
`ContactNo` varchar(20) NOT NULL,
`Address` varchar(255) NOT NULL,
`Params` text NOT NULL,
`Province` varchar(255) NOT NULL,
`ZipCode` varchar(255) NOT NULL,
`Status` Boolean NOT NULL DEFAULT '0',
`AddedBy` int(11) NOT NULL,
`AddedOn` date NOT NULL,
`ModifiedOn` date DEFAULT NULL
) ENGINE =InnoDB DEFAULT CHARSET=latin1;
But while creating third table as
CREATE TABLE IF NOT EXISTS `lawncare_message` (
`ID` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`Reason` int(5) NOT NULL,
`Subject` text NOT NULL,
`Description` text NOT NULL,
`Customer` int(11) NOT NULL,
`CustomerUser` varchar(255) NOT NULL,
`CustomerEmail` varchar(255) NOT NULL,
`SendTo` int(11) NOT NULL,
`SendToUser` varchar(255) NOT NULL,
`SendToEmail` varchar(255) NOT NULL,
`Status` int(5) NOT NULL DEFAULT '0',
`AddedBy` int(11) NOT NULL,
`AddedOn` date NOT NULL
FOREIGN KEY (SendTo, SendToUser, SendToEmail)
REFERENCES lawncare_user(ID, UserName, Email)
ON UPDATE CASCADE ,
FOREIGN KEY (Customer, CustomerUser, CustomerEmail)
REFERENCES lawncare_customer(ID, FirstName,Email)
ON UPDATE CASCADE
) ENGINE =InnoDB DEFAULT CHARSET=latin1
I get #1215 - Cannot add foreign key constraint , error in mysql tried adding foreign keys after creating table but it still gives the same error. I don't know what I'm doing wrong here.
First of all Check whether you have applied indexes on the keys.
As per your code their is no point in referencing id,UserName and Email.
Only id is enough for referencing.
Check the following code
CREATE TABLE IF NOT EXISTS `lawncare_message` (
`ID` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`Reason` int(5) NOT NULL,
`Subject` text NOT NULL,
`Description` text NOT NULL,
`Customer` int(11) NOT NULL,
`CustomerUser` varchar(255) NOT NULL,
`CustomerEmail` varchar(255) NOT NULL,
`SendTo` int(11) NOT NULL,
`SendToUser` varchar(255) NOT NULL,
`SendToEmail` varchar(255) NOT NULL,
`Status` int(5) NOT NULL DEFAULT '0',
`AddedBy` int(11) NOT NULL,
`AddedOn` date NOT NULL,
FOREIGN KEY (SendTo)
REFERENCES lawncare_user(ID)
ON UPDATE CASCADE ,
FOREIGN KEY (Customer)
REFERENCES lawncare_customer(ID)
ON UPDATE CASCADE
) ENGINE =InnoDB DEFAULT CHARSET=latin1
When i run this query i'm keeping getting this error Database query failed 1054 - Unknown column 'cv.employeeIDFK' in 'on clause'
This only happen when I add the category in my query
FROM opjb_cv AS cv , opjb_cvCategory AS cv_cat
AND cv_cat.categoryIDFK IN ( 1,2,3,4,5,11,22,24,26,28 )
AND cv_cat.cvIDFK = cv.id
This is my query which is failing as you can see i have added all information but still its failing i cant seem to find anything wrong with this.
SELECT DISTINCT cv.id, cv.targetJobTitle, cv.targetJobTitleAlt, cv.recentEmployer, employee.firstName,
employee.surname, cv.recentJobTitle, cv.modifyAt, cv.city, cv.countryCountyFK, cv.countryStatesFK, cv.countryISO2FK, cv.experienceIDFK,
cv.careerIDFK, cv.areYouAuth, country.countryName, cv.employeeIDFK as user_id ,
match ( cv.title, cv.recentJobTitle, cv.targetJobTitle, cv.targetJobTitleAlt ) AGAINST ('desktop' IN BOOLEAN MODE) AS relevance
FROM opjb_cv AS cv , opjb_cvCategory AS cv_cat
JOIN opjb_employee AS employee ON cv.employeeIDFK = employee.id
JOIN opjb_country AS country ON cv.countryISO2FK=country.iso2
JOIN opjb_experience AS experience ON cv.experienceIDFK = experience.id
JOIN opjb_type AS type ON cv.jobTypeIDFK = type.id
JOIN opjb_education AS education ON cv.educationIDFK = education.id
JOIN opjb_countryStates as countryStates ON cv.countryStatesFK = countryStates.code
WHERE cv.showTo=1
AND cv.status=1
AND cv.countryISO2FK='GB'
AND match ( cv.title, cv.recentJobTitle, cv.targetJobTitle, cv.targetJobTitleAlt ) AGAINST ('desktop' IN BOOLEAN MODE )
AND cv_cat.categoryIDFK IN ( 1,2,3,4,5,11,22,24,26,28 )
AND cv_cat.cvIDFK = cv.id
AND experience.id=5
AND type.id=1
AND education.id=7
AND cv.modifyAt > NOW() - INTERVAL 3 DAY AND ( cv.salaryMin <= 48000 OR cv.salaryMax <= 48000 )
AND cv.countryStatesFK ='EG'
ORDER BY relevance DESC
These are all the tables which is involde in this query.
CREATE TABLE IF NOT EXISTS `opjb_country` (
`iso2` char(2) NOT NULL,
`iso3` char(3) NOT NULL,
`isoNo` smallint(3) NOT NULL,
`countryName` varchar(100) NOT NULL,
`regionIDFK` int(11) NOT NULL,
`isActive` tinyint(1) NOT NULL default '0',
PRIMARY KEY (`iso2`),
KEY `regionIDFK` (`regionIDFK`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `opjb_countryStates`
--
CREATE TABLE IF NOT EXISTS `opjb_countryStates` (
`code` varchar(40) NOT NULL default '',
`name` varchar(100) default NULL,
`countryISO2FK` char(2) NOT NULL default 'US',
`isActive` tinyint(1) NOT NULL default '0',
PRIMARY KEY (`code`,`countryISO2FK`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `opjb_cv`
--
CREATE TABLE IF NOT EXISTS `opjb_cv` (
`id` int(11) NOT NULL auto_increment,
`type` tinyint(1) NOT NULL default '0',
`fileName` varchar(100) NOT NULL,
`fileType` varchar(15) NOT NULL,
`fileExe` varchar(5) NOT NULL,
`fileSize` int(11) NOT NULL default '0',
`filePath` varchar(255) NOT NULL,
`originalName` varchar(100) NOT NULL,
`fileHash` varchar(40) NOT NULL,
`title` varchar(30) NOT NULL,
`description` varchar(255) NOT NULL,
`showTo` tinyint(1) NOT NULL default '0',
`defaultCV` tinyint(1) NOT NULL default '0',
`targetJobTitle` varchar(100) NOT NULL,
`targetJobTitleAlt` varchar(100) NOT NULL,
`educationIDFK` int(6) NOT NULL default '0',
`careerIDFK` int(6) NOT NULL default '0',
`city` varchar(100) NOT NULL,
`areYouAuth` varchar(100) NOT NULL,
`recentJobTitle` varchar(100) NOT NULL,
`recentEmployer` varchar(100) NOT NULL,
`recentIndustry` varchar(100) NOT NULL,
`recentCareer` int(6) NOT NULL default '0',
`recentStartDate` date NOT NULL,
`recentEndDate` varchar(50) NOT NULL,
`jobTypeIDFK` int(6) NOT NULL default '0',
`jobStatusIDFK` int(6) NOT NULL default '0',
`salaryMin` varchar(20) NOT NULL default '0',
`salaryMax` varchar(20) NOT NULL default '0',
`salaryCurrency` varchar(5) NOT NULL default 'GBP',
`salaryType` tinyint(2) NOT NULL default '5',
`relocate` tinyint(1) NOT NULL default '0',
`willing_to_travel` tinyint(2) NOT NULL default '0',
`availability` tinyint(1) NOT NULL default '0',
`startDate` varchar(30) NOT NULL,
`positions` varchar(100) NOT NULL,
`userComments` text,
`noViews` int(7) NOT NULL default '0',
`status` tinyint(1) NOT NULL default '0',
`adminComments` text,
`employeeIDFK` int(11) NOT NULL default '0',
`countryISO2FK` char(2) NOT NULL default 'US',
`countryStatesFK` varchar(100) NOT NULL,
`countryCountyFK` varchar(100) NOT NULL,
`experienceIDFK` int(6) NOT NULL default '0',
`modifyAt` datetime NOT NULL,
`createdAt` datetime NOT NULL,
PRIMARY KEY (`id`),
KEY `employeeIDFK` (`employeeIDFK`),
KEY `countryISO2FK` (`countryISO2FK`),
FULLTEXT KEY `searchCV` (`title`,`targetJobTitle`,`targetJobTitleAlt`,`recentJobTitle`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;
-- --------------------------------------------------------
--
-- Table structure for table `opjb_cvCategory`
--
CREATE TABLE IF NOT EXISTS `opjb_cvCategory` (
`cvIDFK` int(11) NOT NULL default '0',
`categoryIDFK` int(11) NOT NULL default '0',
PRIMARY KEY (`cvIDFK`,`categoryIDFK`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `opjb_education`
--
CREATE TABLE IF NOT EXISTS `opjb_education` (
`id` int(6) NOT NULL auto_increment,
`educationName` varchar(100) NOT NULL,
`lang` varchar(50) NOT NULL default 'english',
`isActive` tinyint(1) NOT NULL default '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=11 ;
-- --------------------------------------------------------
--
-- Table structure for table `opjb_employee`
--
CREATE TABLE IF NOT EXISTS `opjb_employee` (
`id` int(11) NOT NULL auto_increment,
`emailAddress` varchar(100) NOT NULL,
`username` varchar(30) NOT NULL,
`passwd` varchar(40) NOT NULL,
`title` varchar(20) NOT NULL,
`firstName` varchar(100) NOT NULL,
`middleName` varchar(50) NOT NULL,
`surname` varchar(100) NOT NULL,
`address` varchar(150) NOT NULL,
`address2` varchar(100) NOT NULL,
`city` varchar(100) NOT NULL,
`countryCountyFK` varchar(100) NOT NULL,
`countryStatesFK` varchar(100) NOT NULL,
`countryISO2FK` char(2) NOT NULL default 'US',
`postCode` varchar(20) NOT NULL,
`careerStatus` tinyint(1) NOT NULL default '0',
`contPref` tinyint(1) NOT NULL default '0',
`webSite` varchar(100) NOT NULL,
`job_title` varchar(255) NOT NULL,
`recent_employer` varchar(255) NOT NULL,
`mobile_no` varchar(30) NOT NULL,
`home_no` varchar(30) NOT NULL,
`categoryIDFK` int(6) default NULL,
`careerDegreeIDFK` int(6) default NULL,
`educationIDFK` int(6) default NULL,
`experienceIDFK` int(6) default NULL,
`pers_statement` text,
`actKey` varchar(100) NOT NULL,
`comments` varchar(255) NOT NULL,
`status` tinyint(1) NOT NULL default '0',
`isActive` tinyint(1) NOT NULL default '0',
`lastVisit` datetime NOT NULL,
`modifyAt` datetime NOT NULL,
`createdAt` datetime NOT NULL,
`createip` varchar(20) NOT NULL default '0',
`loginip` varchar(20) NOT NULL default '0',
PRIMARY KEY (`id`),
UNIQUE KEY `emailAddress` (`emailAddress`),
UNIQUE KEY `username` (`username`),
KEY `city` (`city`,`countryCountyFK`),
KEY `countryISO2FK` (`countryISO2FK`),
KEY `idx_fullname` (`firstName`,`surname`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
-- --------------------------------------------------------
--
-- Table structure for table `opjb_experience`
--
CREATE TABLE IF NOT EXISTS `opjb_experience` (
`id` int(6) NOT NULL auto_increment,
`experienceName` varchar(100) NOT NULL,
`lang` varchar(50) NOT NULL default 'english',
`isActive` tinyint(1) NOT NULL default '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=8 ;
-- --------------------------------------------------------
--
-- Table structure for table `opjb_type`
--
CREATE TABLE IF NOT EXISTS `opjb_type` (
`id` int(6) NOT NULL auto_increment,
`typeName` varchar(100) NOT NULL,
`lang` varchar(50) NOT NULL default 'english',
`isActive` tinyint(1) NOT NULL default '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ;
CREATE TABLE `t_keyword_stat_ga` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`keyword_id` int(11) DEFAULT NULL,
`targeturl_id` int(11) DEFAULT NULL,
`entrances` int(11) DEFAULT NULL,
`track_date` date DEFAULT NULL,
`traffic_date` date DEFAULT NULL,
`own_domain_id` int(11) DEFAULT NULL,
`medium` varchar(255) DEFAULT NULL,
`pageviews` int(11) DEFAULT NULL,
`exits` int(11) DEFAULT NULL,
`bounces` int(11) DEFAULT NULL,
`source` varchar(255) DEFAULT NULL,
KEY `id` (`id`),
KEY `traffic_date` (`traffic_date`),
KEY `FK_keywordStatGA_targeturl` (`targeturl_id`,`traffic_date`),
KEY `own_domain_id` (`own_domain_id`,`traffic_date`),
KEY `keyword_id` (`keyword_id`,`own_domain_id`,`traffic_date`)
) ENGINE=InnoDB AUTO_INCREMENT=1707411331 DEFAULT CHARSET=utf8;
CREATE TABLE `t_keyword_conversion_ga` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`own_domain_id` int(11) DEFAULT NULL,
`keyword_id` int(11) DEFAULT NULL,
`traffic_date` date DEFAULT NULL,
`targeturl_id` int(11) DEFAULT NULL,
`entrance` int(11) DEFAULT NULL,
`transactions` int(11) DEFAULT NULL,
`item_revenue` decimal(9,2) DEFAULT NULL,
`goal1completions` int(11) DEFAULT NULL,
`goal2completions` int(11) DEFAULT NULL,
`goal3completions` int(11) DEFAULT NULL,
`goal4completions` int(11) DEFAULT NULL,
`goal5completions` int(11) DEFAULT NULL,
`goal6completions` int(11) DEFAULT NULL,
`goal7completions` int(11) DEFAULT NULL,
`goal8completions` int(11) DEFAULT NULL,
`goal9completions` int(11) DEFAULT NULL,
`goal10completions` int(11) DEFAULT NULL,
`goal1Value` decimal(9,2) DEFAULT NULL,
`goal2Value` decimal(9,2) DEFAULT NULL,
`goal3Value` decimal(9,2) DEFAULT NULL,
`goal4Value` decimal(9,2) DEFAULT NULL,
`goal5Value` decimal(9,2) DEFAULT NULL,
`goal6Value` decimal(9,2) DEFAULT NULL,
`goal7Value` decimal(9,2) DEFAULT NULL,
`goal8Value` decimal(9,2) DEFAULT NULL,
`goal9Value` decimal(9,2) DEFAULT NULL,
`goal10Value` decimal(9,2) DEFAULT NULL,
`medium` varchar(255) DEFAULT NULL,
`source` varchar(255) DEFAULT NULL,
KEY `id` (`id`),
KEY `keyword_id` (`keyword_id`),
KEY `traffic_date` (`traffic_date`),
KEY `own_domain_id` (`own_domain_id`,`traffic_date`),
KEY `targeturl_id` (`targeturl_id`)
) ENGINE=InnoDB AUTO_INCREMENT=526248221 DEFAULT CHARSET=utf8;
i have a tables like _keyword_Stat_ga and t_keyword_Stat_conversion
I Need to export all data after October 31 2011 from the t_keyword_Stat_ga
and t_keyword_Stat_conversion tables.
Import the backup into a ICE instance (for maximum compression) or an ARCHIVE table.
Need to drop the partitions in DB1 on the above tables through October 2011
We then need a before and after summary of disk usage