Solved

smaller table, same rows of data but less columns

Posted on 2013-12-09
5
246 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
Comment Utility
and the question is ?

so far it looks legit.
0
 

Author Comment

by:rgb192
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
thanks
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
I have been using r1soft Continuous Data Protection (http://www.r1soft.com/linux-cdp/) for many years now with the mySQL Addon and wanted to share a trick I have used several times. For those of us that don't have the luxury of using all transact…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now