Solved

smaller table, same rows of data but less columns

Posted on 2013-12-09
5
250 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
By, Vadim Tkachenko. In this article we’ll look at ClickHouse on its one year anniversary.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

617 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