How to do Indexing of database tables in phpMyAdmin - mysql

I want to boost up my database speed each time when new query hit to database table. Can anybody help me out with how indexing works in phpMyAdmin & how to do it??

Select a table
click on page Structure
Below the column section you can found an index section
Found the Create an index on x columns
Press the button GO

you can use create index statement:
create index idx_username on users(username)
what actually means: "i want to create index called idx_username on table users on column username"

Set the index from PHPMYADMIN.
I marked the index button in yellow.

Related

Clear Table Without Deleting Index

When I run the following VBA it does what I need.
DoCmd.RunSQL "DELETE * FROM tmp_tbl_order_short"
I then repopulate the table but when I run a query against that data it is dog slow. Reason is that the index is gone.
Can I recreate an index via VBA or is there another way of clearing the table without removing the index?
What do you mean by 'index is gone'?? If field was indexed, then when you add new data, it will re-index. You are not deleting table and recreating it, which you can do, if needed, with following SQL statements that you can execute:
DROP TABLE tempTable;
CREATE TABLE tempTable(all fields)
and Follow by creating index:
CREATE INDEX myTempIndex
ON tempTable (FieldToIndex)
In my opinion, something else is making your query go slower, perhaps wrong field indexed etc.
Ok ... my bad. During development of this process the query that repopulated the table was a 'make table' query which was fine until I realized an index was required. The original VBA sequence cleared the table and then I THOUGHT appended the new data.
So the 'DoCmd.RunSQL "DELETE * FROM tmp_tbl_order_short"' was not deleting the index, the make table query was.

How to get a column creation script workbench?

I upload my sql database on workbench to add properly a new relation between two tables. But I only need The ALTER TABLE .. ADD .. AFTER script not the CREATE TABLE because it's already created with inserted values.
So is there any solution to get the script only to create the column with its foreign keys ?
Thank you in advance.
Not sure when this function was introduced, but with workbench 5.2.33 you can obtaing the ALTER statment by selecting the table you want to alter, and right-click and select ALTER
After this you can define the Foreing Keys
And when you press "Apply", you can see and copy the script
Once you have the script, click "cancel" and don't apply the changes.

Clarification on MySQL 5.6 using IN PLACE alter table for adding/dropping the same index

From the docs:
An ALTER TABLE statement that contains DROP INDEX and ADD INDEX
clauses that both name the same index uses a table copy, not Fast
Index Creation.
This is a bit unclear to me. Is it talking about the NAME of the index? Can someone give an example of a query in which MySQL resorts to a table copy?
Indeed, it sounds like this line is about:
An (One, single) ALTER TABLE statement
that contains (both) a DROP INDEX and an ADD INDEX clause
and both clauses name the same index
and states that such a statement uses a table copy, not Fast Index Creation.
Such a statement would be:
ALTER TABLE MyTable
DROP INDEX MyIndex
ADD INDEX MyIndex(MyColumn);
The documentation is not really clear about the reason behind this, but I think the database want to create an index first and then drop the other index, so the statement by itself can more easily be made atomic. (Creating the index might fail.) If the index name itself is used in the storage as well, that order of first creating then dropping would give a conflict.
After all, fast index creation is a relatively new feature, so they might improve this over time.

What is reason for FULLTEXT index couldn't add for huge data set?

In my database contains 3 millions records. Initially haven't any FULLTEXT index in my database. Now I'm trying to add FULLTEXT index using Create index statement, that take huge time and browser showing connecting and ram goes to 70%. I feel that nothing happen to database. what should I follow? Is there any other way to add FULLTEXT index? If I'm add FULLTEXT index is that affect to next inserting values? 1st I want to anyhow add FULLTEXT index to my table. I'm using Xammp MySql database.
1.Create the dummy table like your original table structure.
2.create indexes on your dummy table which want you.
3.take a dump from your original table and import to dummy.
4.drop the original table and rename the dummy table to original name.

How to add on delete cascade and on update restrict using phpmyadmin?

I want to add 'On delete cascade and on update restrict' on foreign keys through phpmyadmin user Interface instead of executing query.
I generally use Heidisql control panel for doing these actions. And now I'm having hard time doing the same on phpmyadmin.
Any idea?
In the tab where you define the table structure, you get the list of columns and their properties and underneath that there should be a link "relation view", between "print view", and "propose table structure."
That's where you want to go, but you have to have created the index on both tables already.
Also, you might want to make sure you're using mysql's innoDB storage engine.
Edit : An image is worth 1000 words :
Cimbali's answer worked for me, but things were placed a little differently, so in case you're also looking for the "relation view" link, try looking there:
It should take you there:
Key fact:
1. Both table must be have innodb storage engine.
2. The datatype and length should be same in both table.
3. The field in 2nd table should be created as index.
Hope it will help someone...