Solved

smaller table, same rows of data but less columns

Posted on 2013-12-09
5
248 Views
Last Modified: 2013-12-09
I have a query that takes a long time to run so I want to make the table smaller to test to see if the query can run quicker

CREATE TABLE `a_messages2` (
  `a_messages_id` int(11) NOT NULL AUTO_INCREMENT,
  `conversation_id` bigint(20) DEFAULT NULL,
  `profile_id` varchar(20) DEFAULT NULL,
  `sender` varchar(20) DEFAULT NULL,
  `message_id` bigint(20) DEFAULT NULL,
  `message_text` varchar(1000) DEFAULT NULL,
  `dateAgo` varchar(20) DEFAULT NULL,
  `message_read` tinyint(4) DEFAULT NULL,
  `this_user` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`a_messages_id`),
  UNIQUE KEY `unique_message_id` (`message_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

Open in new window



I want to create a similar smaller table (less columns, no primary key, no unique key) and copy the rows of data

CREATE TABLE `a_messages2_smaller` (
  `profile_id` varchar(20) DEFAULT NULL,
  `sender` varchar(20) DEFAULT NULL,
  `message_id` bigint(20) DEFAULT NULL,
  `this_user` varchar(20) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

Open in new window

0
Comment
Question by:rgb192
  • 3
5 Comments
 
LVL 11

Expert Comment

by:Radek Baranowski
ID: 39705996
and the question is ?

so far it looks legit.
0
 

Author Comment

by:rgb192
ID: 39706373
there is already data in a_messages_2
I want to create a smaller table a_messages_2_smaller and insert the same data
0
 
LVL 32

Accepted Solution

by:
Daniel Wilson earned 500 total points
ID: 39707127
insert into a_messages2_smaller (profile_id, sender, message_id, this_user)
(Select profile_id, sender, message_id, this_user from a_messages2);

However, I don't anticipate that will help your query speed. What is the query that's giving you trouble?  And approximately how many rows do you have?  Some careful index design is more likely to help.
0
 

Author Comment

by:rgb192
ID: 39707594
your insert worked and the query ran much quicker but maybe index would be better, which will be another question.
0
 

Author Closing Comment

by:rgb192
ID: 39707595
thanks
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword This is an old article.  Instead of using the MySQL extension that was used in the original code examples, please choose one of the currently supported database extensions instead.  More information is available here: MySQLi / PDO (http://…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question