How to find how often data is updated in mysql - mysql

I have a view - 'test.view', I would like to know at least the last 10 updates to this view.
Any help appreciated

Related

SQL find users that consistently search with in five months during the whole year

I am facing a SQL problem that I can't think a way to solve it.
Please check the below table.
I want to find users that search at least once within consistent 5 months
Can someone help me please?

Best way to update SQL tables while querying it

So I have a MySQL table where it needs to get updated on a daily basis and the structure look like the following:
siteid user proportion
1000 1 0.1
1000 2 0.5
1000 3 0.4
Problem is that other parts of the code need to access this table while its being updated while the update might take several minutes everyday. This is what happens on a everyday:
A task runs around 8am EST everyday to update the above table based on yesterday's data. This update might take up to half an hour.
Users should have access to this table anytime to get the most recent updates
I have came up about the following ideas but pretty sure none of them would for work me:
Create a temp table to access it while updating the main table: this does not sound like a good idea since there are five of those tables and not feasible to switch between temp and main table.
Put a halt on all operations while the table being updated which is impossible since other code accessing the tables must be always up and running.
I would be very grateful for any help toward any possible solutions for this. I know this is broad and there might not be any right or wrong answers, mostly interested in your experiences with similar situations.
NOTES:
There tables have millions of rows stored in them.
I am using MySQL here and as mentioned before not able to lock transactions since everything must be live.
Backend code is written in python
You can accomplish this maybe this way?
Have two tables with the same structure, names ending in _A and _B.
Have a view that can be toggled on the fly to point to _A or _B (In Oracle we would use a synonym).
In your update procedure:
1. Copy data from _A to _B.
2. Point view to _A (update the view).
3. Do Updates to _B
4. Point view to _B (update the view).
Next time you run, you'll repeat the process, but the _A references become _B and vice versa. You might want to way to track whatever the "current" tables are (_A OR _B).

Mysql table queries very slow

I'm busy looking at building a matchmaking (dating-) site. The tables and queries are set up in a way i'm not happy with. It's still under construction so i'm happy to change anything in order to get it to work properly. It was very speedy until i decided to fill the database with loads of records to see how it performs.
Beware, this is a rather long post with lots (i hope the right...) information.
I have been googling' and reading in books for days now but A) the query performs very slowly (no wonder, it's no good i think) and B) i'm not getting any further with it.
So i hope somebody can help me to tell me what i'm doing wrong, what i should be doing and how to speed the query up. It's taking as long as 10-20 seconds to generate a result set and thats not good, anybody knows..
The information:
I have a table called 'profiles' with about 500.000 records in it. (at this time, could be more in the future)
Profiles table:
example contents:
Every answer to a question gets inserted to the profiles table, as a row. There are questions who are multiple choice so every answer selected by the member will be inserted as a new row in the profiles table and there are questions which can only have one answer thus one row in the profiles table.
Also, there is the table 'status' in which i keep record of members blocking or favoriting each other:
example contents:
Once the member fills in his/her criteria, php dynamically builds the query which needs to fetch records from the profiles table:
You can imagine how big this select query will get if all 90 questions are in the sql statement above..
Explain tells me this:
Basically i want to query the profiles table, fetching members matching the given criteria. The criteria are:
the criteria that the member who searches entered as his/hers will retrieve matching members as a result
the current member (the one who searches) should not be in the result(s)
members who are present in the status table with a status of 'block' should not be in the result(s)
I'm aware (now) that the 'where in' clauses are not very fast, the indexes could be wrong and the maybe my whole table lay-out needs to be different, but i hope somebody can either point me or help me in the right direction. After a day of trying and googling' i'm at my wits end.
If you need more information, just shout! Hopefully somebody can help me.

SQL table setup and performance

Im working on a website that is bassed around voting for posts. the website contains a 'hot' page will basicly sorts by most votes in the last 24h.
i been thinking about how to set it up table wise for the last few days and im wondering what would be the best option performance wise.
at the moment i was thinking about building a table that makes a new row for every vote and give it the date the vote was made and a id linked to the post and get all the other details like titel and auther from a other table, but sinds the table holding the votes will get really big really fast like this would it be a good idea to remove all the rows that wont get used anymore after 24h hours?
so basicly if its a good idea to make a cronjob that removes all the rows that got made longer then 24hours ago?
It might be a good idea to remove info from the table but remember that SQL works pretty fine with millions of rows!
In your case, I'd run a cronjob every day that removes the rows that got made longer then 48h! I think that this would be enough.

how can I add records through a query in access?

Before I remade this simple database, I was able to perform a query and update and insert new records from that query. I can no longer do this and can't figure out why.
I'm not very knowledgeable with access so any help would be greatly appreciated. I have a feeling that this may have something to do with the auto number column that no longer exists. Basically, it wouldn't allow me to change the data type after I had entered data into the table. I needed to do this to preserve the primary key as they match the client's records and cannot be changed.
If I understand you right you have a query that used to work (and insert records in a table) and now doewsn't work anymore? Can you post the SQL of the query and the structure of the table that you are inserting in? That will make it a lot easier for the rest of the world to help you.