Search for a recent added keywords [closed] - mysql

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Say if there is a Table that has 100 Million Records.. More and more data keeps getting updated now and then. Your mission is to search for a recently added keyword say "srinu" from that table each and every 30 seconds and to display it.
What is the efficient way to do this ?
No need to write any code. Just give your views/thoughts on this.

This is a rather abstract question and will have a lot of opinionated answers.
What is the criteria for "recently added"?
If I needed a quick query to see what records were added within the last 30 seconds
I would create a trigger and a secondary lookup table
after update and after insert insert into recently_added;
and create an event to delete from recently_added where the datetime field is less than than 30 seconds ago and run it every 30 seconds
This step can be moved to the trigger and a criteria added to the select instead
This way I would SELECT * FROM recently_added if there were no records found I know that no records were updated within the last 30 seconds. Otherwise all of the keywords updated within the last 30 seconds are listed

Use Elasticsearch. First index data into database using any river like MongoDB River Plugin for ElasticSearch. So that if any new data is added to database it automatically syncs with elasticsearch and from there you can search the recent doc added.

Related

MySQL - need help .One table or multiple tables? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
I must to make a decision if I split my table in more tables or I keep all in one table. According to my calculation if I will keep all in one table my table will have estimated 300.000 rows per year. Some people say to me to split table for every year. example 2019_table..
Some people say to split table in 4 tables(subcategories). I need an advice how to do it.
This is my current table https://ibb.co/jfZMKQJ
300K records is not really a large amount, and even over a decade, it is only 3 million records, which also is not very large. Assuming you can tune your database with appropriate indices, I don't see any reason to split into multiple tables. Even if you did have the need for this, you could try something like partitioning the table first (see the documentation).
300K records is not a large amount. Instead of splitting the tables, you better have to put an index on your datetime field assuming it is one of the fields you will use to filter your data.
See this answer for more details: Is it a good idea to index datetime field in mysql?

Copy rows filtered on a search criteria from one table to another in MySQL [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
Using MySQL, I want to retrieve all rows from a table A where a field contains "EQ" for example, copy them into table B (which has exactly the same field), and then delete them from table A.
I heard about triggers. Is that the right approach?
You need 2 SQL statements. First for inserting the data rows from A to B, and then for deleting those rows from A.
INSERT INTO B
SELECT *
FROM A
WHERE Field LIKE '%EQ%';
DELETE
FROM A
WHERE Field LIKE '%EQ%';
Triggers are a way to automate some activities when some other activity in a separate table happens. If you need to make sure that the above 2 operations should be triggered as soon someone INSERTS/DELETES/UPDATES on some other table, then you can create a trigger for that purpose. But with the simple requirement you gave above without any such dependency, I do not see a need of a trigger here.
If you do have such dependency and need, you have to provide proper requirements with details here.

SQL programming-how to correctly alter date and datetime [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I am looking for really good examples on how to work with date or datetime or how to update them correctly on a databases so that they can be "up to date". I have had this issues before with sql, when using date or datetime they would not update after I use them. The only time I could modify them would be when inserting into the table.
Also, the same applied when I used a JDBC connector to create an interface for the database. The data would modify only at inserting and not when altering.
What to use when altering a table? Update?
Example: I have an online store in which I have "Products for sale" with fields in which day I created the Product and what day I restocked(when creating restocked will have the same value as created.). I create a new product, after 3 days I restock. How can I correctly alter the product so that the day I restocked is today, not 3 days away when I first created the product?
I am using MySQL WORKBENCH 6.0 CE.
Any suggestions will be appreciated.
Thank you!

Howto efficiently search a huge mysql table [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
if I had a mysql table that has, lets say 300 million rows, how would I search for a row using
SELECT id WHERE coloumn = "abc" ;
most efficiently? Can I prepare the data so it would help the sql searching through the data? Or does it parse the rows row by row?
The SQL 101 answer here is an index using CREATE INDEX:
CREATE INDEX column_index ON table_name (`column_name`)
This of course depends on your schema. You can index more than one column as well and can apply UNIQUE constraints to ensure that each value is used only once.
On large tables the CREATE INDEX operation will be brutally slow to create the first time, so schedule some downtime if necessary. Once created it will be kept up-to-date automatically.

Insert 1 Million Records in MySQL [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have a simple table 'MyCombs' with 3 columns. ID, Start & End. ID is autoincrement so I have no problem with that. For Start & End points, I have 1million records. These records are different. I have created Insert queries for these 1 miilion records. Now i am facing a problem. When i try to simply run the queries by copying 50,000 records each time in phpMyAdmin, it does not insert these records in table. Loading, Loading. I saw some solution where we have to create a sql format file. I tried but was not able to create such file. Fairly saying, i am completely new to this. Is there anyway i can insert these records into table??
You can achieve it by using 'Bulk Insert' either in MySql or SqlServer !!!
For More Information...refer the following link..
https://dev.mysql.com/doc/refman/5.5/en/optimizing-innodb-bulk-data-loading.html