MySQL does not recognize possible_keys in join - mysql

I tried to query by join 2 tables giao_vien and lop_mon.
The following is my tables structure:
CREATE TABLE `lop_mon` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`key_index` varchar(250) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`khoi_key_index` varchar(250) DEFAULT NULL,
`lop_key_index` varchar(250) DEFAULT NULL,
`gv_key_index` varchar(250) DEFAULT NULL,
`mon_key_index` varchar(250) DEFAULT NULL,
`ma_so` varchar(50) DEFAULT NULL,
`ma_phong` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
`nam_hoc` int(11) NOT NULL,
`ma_truong` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
`ma_khoi` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`ma_lop` varchar(50) NOT NULL,
`ma_giao_vien` varchar(50) NOT NULL,
`ma_mon_hoc` varchar(50) DEFAULT NULL,
`hoc_ky` tinyint(4) NOT NULL,
`guid` varchar(250) DEFAULT NULL,
`processid_monhoc` int(11) DEFAULT NULL,
`processid_giaovien` int(11) DEFAULT NULL,
`processid_canbo` int(11) DEFAULT NULL,
`source_data` varchar(50) DEFAULT NULL,
`ten_gv_chat_ph` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
`ma_giao_vien_bgd` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
`ma_lop_bgd` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
`ma_mon_hoc_bgd` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
`gv_guid` char(36) DEFAULT NULL,
`truong_key_index` varchar(255) DEFAULT NULL,
`create_date` datetime DEFAULT NULL,
`updatedAt` datetime DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `key_UNIQUE` (`key_index`),
UNIQUE KEY `unique_lop_mon_gv_keyindex_hoc_ky` (`lop_key_index`,`gv_key_index`,`mon_key_index`,`hoc_ky`) USING BTREE,
KEY `lopmon_keyindex` (`mon_key_index`),
KEY `lopmon_idx_mamonhoc` (`ma_mon_hoc`),
KEY `idx_gv_key_index` (`gv_key_index`),
KEY `lopmon_idx_lop_key_index` (`lop_key_index`),
KEY `lopmon_idx_key_index` (`khoi_key_index`),
KEY `lopmon_idx_ma_truong` (`ma_truong`),
KEY `lopmon_idx_nam_hoc` (`nam_hoc`),
KEY `lopmon_idx_ma_khoi` (`ma_khoi`),
KEY `lopmon_idx_hoc_ky` (`hoc_ky`),
KEY `lopmon_idx_key_lop_mon` (`lop_key_index`,`mon_key_index`),
KEY `lopmon_idx_key_lop_gv` (`lop_key_index`,`gv_key_index`),
KEY `lopmon_idx_key_mon_gv` (`mon_key_index`,`gv_key_index`),
KEY `lopmon_idx_key_lop_mon_gv` (`lop_key_index`,`mon_key_index`,`gv_key_index`),
KEY `lopmon_idx_key_truong_lop_mon_gv` (`ma_truong`,`lop_key_index`,`mon_key_index`,`gv_key_index`),
KEY `lop_mon__index_gv_guid` (`gv_guid`),
KEY `lopmon_idx_truong_key_index` (`truong_key_index`)
) ENGINE=MyISAM AUTO_INCREMENT=23142297 DEFAULT CHARSET=latin1
My Query:
select * from giao_vien inner join lop_mon on lop_mon.gv_key_index = giao_vien.key_index
where giao_vien.key_index = 'shcm_2019_01645344018'
When I explain it:
MySQL does not recognize the key:
KEY `idx_gv_key_index` (`gv_key_index`)
I check another query:
SELECT * FROM enetviet.lop_mon where gv_key_index = 'shcm_2019_01645344018';
The key idx_gv_key_index is still work. I don't know what is the problem.

Related

What is the ACTION keyword in MySQL

What is the Action keyword in MySQL? I'm converting a MySQL query into cockroachdb query and the MySQL query I'm seeing is:
CREATE TABLE tabDocType Action (
name varchar(140) COLLATE utf8mb4_unicode_ci NOT NULL,
creation TIMESTAMP(6) DEFAULT NULL,
modified TIMESTAMP(6) DEFAULT NULL,
modified_by varchar(140) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
owner varchar(140) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
docstatus INT NOT NULL DEFAULT 0,
parent varchar(140) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
parentfield varchar(140) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
parenttype varchar(140) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
idx INT NOT NULL DEFAULT 0,
label varchar(140) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
group varchar(140) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
action_type varchar(140) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
action text COLLATE utf8mb4_unicode_ci DEFAULT NULL,
PRIMARY KEY (name)
);
Also is Link also a keyword? It's not in the docs but I'm not quite sure what it's actually doing here:
CREATE TABLE `tabDocType Link` (
`name` varchar(140) COLLATE utf8mb4_unicode_ci NOT NULL,
`creation` TIMESTAMP(6) DEFAULT NULL,
`modified` TIMESTAMP(6) DEFAULT NULL,
`modified_by` varchar(140) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`owner` varchar(140) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`docstatus` INT NOT NULL DEFAULT 0,
`parent` varchar(140) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`parentfield` varchar(140) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`parenttype` varchar(140) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`idx` INT NOT NULL DEFAULT 0,
`group` varchar(140) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`link_doctype` varchar(140) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`link_fieldname` varchar(140) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
PRIMARY KEY (`name`),
KEY `parent` (`parent`),
KEY `modified` (`modified`)
)
From the docs, https://dev.mysql.com/doc/refman/8.0/en/keywords.html, ACTION seems to be a keyword but it doesn't have details on it.
Perhaps they are not keywords at all but serves a different purpose? Thank you.
So looks like it's not a keyword, it's part of the table name. Spaces are allowed in a table name as long as the name is in the back tick.
https://www.tutorialspoint.com/can-we-create-a-table-with-a-space-in-name-in-mysql
It has nothing to do with reserved words, create table has no ACTION attribute
As you can read up on the home page about create table
Still group in your create table is a reserved word
CREATE TABLE tabDocType (
name varchar(140) COLLATE utf8mb4_unicode_ci NOT NULL,
creation TIMESTAMP(6) DEFAULT NULL,
modified TIMESTAMP(6) DEFAULT NULL,
modified_by varchar(140) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
owner varchar(140) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
docstatus INT NOT NULL DEFAULT 0,
parent varchar(140) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
parentfield varchar(140) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
parenttype varchar(140) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
idx INT NOT NULL DEFAULT 0,
`label` varchar(140) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`group` varchar(140) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
action_type varchar(140) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
action text COLLATE utf8mb4_unicode_ci DEFAULT NULL,
PRIMARY KEY (name)
);
To answer your literal question, ACTION is a reserved word because one of the possible ON DELETE/ON UPDATE reference option values for a foreign key constraint is NO ACTION; see https://dev.mysql.com/doc/refman/8.0/en/create-table-foreign-keys.html

How to import a table that was deleted with foreign keys?

I have deleted a table from my server called 'companies' that has foreign keys and also has relationships with other tables. Now I'm trying to import the table again with a backup I download, but it throws an error of incorrectly formed foreign keys
I have tried to create just the table with 2 charts a name and an id, but it's not working it also throws the error of Foreign key constraint is incorrectly formed.
CREATE TABLE `companies` (
`id` int(10) UNSIGNED NOT NULL,
`company_name` varchar(191) COLLATE utf8_unicode_ci NOT NULL,
`company_email` varchar(191) COLLATE utf8_unicode_ci NOT NULL,
`company_phone` varchar(191) COLLATE utf8_unicode_ci NOT NULL,
`logo` varchar(191) COLLATE utf8_unicode_ci DEFAULT NULL,
`login_background` varchar(191) COLLATE utf8_unicode_ci DEFAULT NULL,
`address` text COLLATE utf8_unicode_ci NOT NULL,
`website` varchar(191) COLLATE utf8_unicode_ci DEFAULT NULL,
`currency_id` int(10) UNSIGNED DEFAULT NULL,
`package_id` int(10) UNSIGNED DEFAULT NULL,
`package_type` enum('monthly','annual') COLLATE utf8_unicode_ci NOT NULL
DEFAULT 'monthly',
`timezone` varchar(191) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'Asia/Kolkata',
`date_format` varchar(20) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'd-m-Y',
`time_format` varchar(20) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'h:i a',
`locale` varchar(191) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'en',
`latitude` decimal(10,8) NOT NULL DEFAULT 26.91243360,
`longitude` decimal(11,8) NOT NULL DEFAULT 75.78727090,
`leaves_start_from` enum('joining_date','year_start') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'joining_date',
`active_theme` enum('default','custom') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'default',
`status` enum('active','inactive','license_expired') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'active',
`last_updated_by` int(10) UNSIGNED DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`stripe_id` varchar(191) COLLATE utf8_unicode_ci DEFAULT NULL,
`card_brand` varchar(191) COLLATE utf8_unicode_ci DEFAULT NULL,
`card_last_four` varchar(191) COLLATE utf8_unicode_ci DEFAULT NULL,
`trial_ends_at` timestamp NULL DEFAULT NULL,
`licence_expire_on` date DEFAULT NULL
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
Error Message:
(Error: 150 "Foreign key constraint is incorrectly formed")
First is to get all foreign keys of "Comapanies" table using this query.
Then drop all foreign keys
ALTER TABLE `companies`
DROP FOREIGN KEY `id_name_fk`;
Then execute your create table statement

Create Hibernate For Joining Table

I have to join 2 tables. The column is want to join is email from candidate table and password from user table. How to do it. Can Someone Help me. candidate
table is Shown Below:
CREATE TABLE `candidate` (`candidate_id` bigint(12) NOT NULL,`user_id`int(11) DEFAULT NULL,`firstname` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,`lastname` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,`dob` date DEFAULT NULL,`gender` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL,`email` varchar(100) COLLATE utf8_unicode_ci NOT NULL,`phone` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, `address_id` int(11) DEFAULT NULL, `profile_title` varchar(120) COLLATE utf8_unicode_ci DEFAULT NULL, `profile_summary` varchar(10000) COLLATE utf8_unicode_ci DEFAULT NULL, `total_experience` int(11) DEFAULT NULL COMMENT 'year,month', `current_location` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, `current_salary` double DEFAULT NULL, `expected_salary` double DEFAULT NULL, `status` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, `percentage` int(45) DEFAULT NULL,`updated_on` timestamp NULL DEFAULT CURRENT_TIMESTAMP, `noticeperiod` int(11) DEFAULT NULL, `martialstatus` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, `currentoffer` double DEFAULT NULL, `idproof` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, `industry` varchar(200) COLLATE utf8_unicode_ci DEFAULT NULL,`functionalarea` varchar(200) COLLATE utf8_unicode_ci DEFAULT NULL, `functionalrole` varchar(200) COLLATE utf8_unicode_ci DEFAULT NULL, `resign` bit(1) DEFAULT NULL,`preferlocation` varchar(1000) COLLATE utf8_unicode_ci DEFAULT NULL,`type` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL,`notice_period_update` timestamp NULL DEFAULT NULL `passport` bit(1) DEFAULT NULL,`gross_salary` double DEFAULT NULL,`profile_type` varchar(12) COLLATE utf8_unicode_ci DEFAULT NULL,`rrm_user_id` int(11) DEFAULT NULL, PRIMARY KEY (`candidate_id`), KEY `Candidate_Address_idx` (`address_id`),KEY `Can_user` (`user_id`),KEY `CandidateStatus_idx` (`status`),KEY `CandidatePercent_idx` (`percentage`),KEY `user_id_idx` (`rrm_user_id`),CONSTRAINT `Can_user` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,CONSTRAINT `Candidate_Address`FOREIGN KEY (`address_id`) REFERENCES `address` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `user_id` FOREIGN KEY (`rrm_user_id`) REFERENCES `user` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
User is:
CREATE TABLE `user` (`id` int(11) NOT NULL AUTO_INCREMENT,`username` varchar(255) COLLATE utf8_unicode_ci NOT NULL,`password` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,`first_name` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `last_name` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,`type` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,`active` bit(1) DEFAULT NULL,`deleted` bit(1) DEFAULT NULL,`timezone` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,`created_on` timestamp NULL DEFAULT NULL,`updated_on` timestamp NULL DEFAULT CURRENT_TIMESTAMP,`activationcode` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,`secure_key` varchar(16) COLLATE utf8_unicode_ci DEFAULT NULL,PRIMARY KEY (`id`),UNIQUE KEY `username_UNIQUE` (`username`)) ENGINE=InnoDB AUTO_INCREMENT=1505 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
You need a very simple SQL query to do this:
SELECT
c.candidate_id,
c.user_id,
c.email,
u.password
FROM
candidate as c
JOIN user as u ON c.user_id = u.user_id
Working example:
http://sqlfiddle.com/#!9/0ba876/1
Try to learn some SQL before you try to progress in this field.
https://www.w3schools.com/sql/

Laravel where method won't works correctly on my server but work right on my Mac

I have a weird problem, this line wont fetch any record on my server but works all right on my computer, mysql and php version are same, and when i cast id field to string it's work on server (Debian), but it is risky because i use where statement with id very much. this is the code:
$myAnswers=Questioner::where('id',$questioner_id)->first()->getLinkedAnsweres()->where("subject_id",Auth::user()->id);
and when i change it to this, it's work right (cast id to string):
$myAnswers=Questioner::where('id',$questioner_id)->first()->getLinkedAnsweres()->where("subject_id",(string)Auth::user()->id);
subject_id and user id are both unsigned_integer with same size.
How can i fix this problem? Should i overwrite where method? or is there any config which cast unsigned int to string in query?
thanks
PS: Tables structure:
users | CREATE TABLE `users` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`family` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`username` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`email` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`gender` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`age` int(11) DEFAULT NULL,
`password` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`default_password` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`access_level` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'subject',
`phone` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`comments` longtext COLLATE utf8_unicode_ci,
`project_limit` int(10) unsigned NOT NULL,
`questioner_limit` int(10) unsigned NOT NULL,
`created_by` int(10) unsigned DEFAULT NULL,
`remember_token` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `users_username_unique` (`username`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci |
answers | CREATE TABLE `answers` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`question_id` int(10) unsigned NOT NULL,
`selected_option` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`subject_id` int(10) unsigned NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci |

Speed up MySQL that contains a large table

We have a MySQL table hosted on an Amazon AWS server, which is some times very very slow while querying. I'm considering restructuring the table with better indexing and columns data types.
Here is the create table structure :
SHOW CREATE TABLE export_users;
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| exportusers | CREATE TABLE `exportusers` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`UAccountID` varchar(50) CHARACTER SET utf8 NOT NULL,
`ApplyURL` text,
`CityName` varchar(64) CHARACTER SET utf8 DEFAULT NULL,
`ClassList` text,
`UCompanyID` varchar(20) DEFAULT NULL,
`UContactCompany` varchar(64) CHARACTER SET utf8 DEFAULT NULL,
`UContactEmail` varchar(512) CHARACTER SET utf8 DEFAULT NULL,
`UContactFax` varchar(32) CHARACTER SET utf8 DEFAULT NULL,
`UContactName` varchar(64) CHARACTER SET utf8 DEFAULT NULL,
`UContactPhone` varchar(100) CHARACTER SET utf8 DEFAULT NULL,
`CountryName` char(2) CHARACTER SET utf8 NOT NULL,
`DateCreated` datetime NOT NULL,
`DateModified` datetime NOT NULL,
`DateSysCreated` datetime NOT NULL,
`DateSysModified` datetime NOT NULL,
`DegreeCode` varchar(200) DEFAULT NULL,
`DegreeCodeDecoded` varchar(512) CHARACTER SET utf8 DEFAULT NULL,
`DisplayCity` varchar(64) CHARACTER SET utf8 DEFAULT NULL,
`DisplayuserID` varchar(32) CHARACTER SET utf8 DEFAULT NULL,
`ExperienceCode` varchar(200) DEFAULT NULL,
`ExperienceCodeDecoded` text,
`ExternalKey` varchar(32) CHARACTER SET utf8 DEFAULT NULL,
`GeoUSZip5` varchar(5) DEFAULT NULL,
`HostSite` char(2) CHARACTER SET utf8 NOT NULL,
`IndustryCode` varchar(128) CHARACTER SET utf8 DEFAULT NULL,
`IndustryCodeDecoded` text,
`IsBOFuser` tinyint(1) DEFAULT NULL,
`IsDiversityuser` tinyint(1) DEFAULT NULL,
`userID` varchar(20) NOT NULL,
`userDesc` text,
`userFunctionCode` text,
`userFunctionCodeDecoded` text,
`userReq` text,
`userSkinDID` varchar(20) DEFAULT NULL,
`userTitle` varchar(128) CHARACTER SET utf8 DEFAULT NULL,
`userType` varchar(512) CHARACTER SET utf8 DEFAULT NULL,
`userTypeDesc` text,
`userTypeCodeDecoded` text,
`Latitude` decimal(10,5) DEFAULT NULL,
`Longitude` decimal(10,5) DEFAULT NULL,
`Location` varchar(70) CHARACTER SET utf8 DEFAULT NULL,
`ManagementCode` varchar(20) CHARACTER SET utf8 DEFAULT NULL,
`MaximumExp` int(11) DEFAULT NULL,
`MinimunExp` int(11) DEFAULT NULL,
`Onet` varchar(10) DEFAULT NULL,
`OnetTitle` text,
`BeginDate` datetime NOT NULL,
`EndDate` datetime NOT NULL,
`PayBaseH` decimal(10,2) DEFAULT NULL,
`PayBaseL` decimal(10,2) DEFAULT NULL,
`PayBonus` decimal(10,2) DEFAULT NULL,
`PayComm` decimal(10,2) DEFAULT NULL,
`PayOther` varchar(64) CHARACTER SET utf8 DEFAULT NULL,
`PayPer` varchar(8) DEFAULT NULL,
`PayType` char(3) DEFAULT NULL,
`PostalCode` varchar(10) DEFAULT NULL,
`PostingPath` varchar(20) NOT NULL,
`Relocate` tinyint(1) DEFAULT NULL,
`RelocateOptions` varchar(5) DEFAULT NULL,
`ScreenerID` varchar(20) DEFAULT NULL,
`SiteID` varchar(1024) CHARACTER SET utf8 DEFAULT NULL,
`SliceList` text,
`StateName` char(30) CHARACTER SET utf8 DEFAULT NULL,
`Status` varchar(50) NOT NULL,
`TextPay` varchar(40) CHARACTER SET utf8 DEFAULT NULL,
`TotalPay` decimal(10,2) DEFAULT NULL,
`TownName` varchar(100) CHARACTER SET utf8 DEFAULT NULL,
`TravelCode` varchar(200) DEFAULT NULL,
`TravelCodeDecoded` text,
`UpgradeList` varchar(64) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `index_jobs_on_UAccountID` (`UAccountID`),
KEY `index_jobs_on_CountryName` (`CountryName`),
KEY `index_jobs_on_DateCreated` (`DateCreated`),
KEY `index_jobs_on_DateModified` (`DateModified`),
KEY `index_jobs_on_DateSysCreated` (`DateSysCreated`),
KEY `index_jobs_on_DateSysModified` (`DateSysModified`),
KEY `index_jobs_on_HostSite` (`HostSite`),
KEY `index_jobs_on_userID` (`userID`),
KEY `index_jobs_on_BeginDate` (`BeginDate`),
KEY `index_jobs_on_EndDate` (`EndDate`),
KEY `index_jobs_on_PostingPath` (`PostingPath`),
KEY `index_jobs_on_Status` (`Status`)
) ENGINE=InnoDB AUTO_INCREMENT=7907436 DEFAULT CHARSET=utf8mb4 |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.27 sec)
Consider Normalization of your schema. Breaking up that one very large entity into much smaller related entities will have the greatest impact on your querying speed.
Normalization involves decomposing a table into less redundant (and smaller) tables but without losing information; defining foreign keys in the old table referencing the primary keys of the new ones. The objective is to isolate data so that additions, deletions, and modifications of an attribute can be made in just one table and then propagated through the rest of the database using the defined foreign keys.