Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

smaller table, same rows of data but less columns

Posted on 2013-12-09
5
Medium Priority
?
251 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 12

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 2000 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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

By, Vadim Tkachenko. In this article we’ll look at ClickHouse on its one year anniversary.
In this article, I’ll talk about multi-threaded slave statistics printed in MySQL error log file.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

705 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