Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    MYSQL


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Read & Write Locks


I need to lock some of my tables for a while with lock tables. However I find how the READ and WRITE locks is implemented in the MyISAM storage engine a little odd. When obtaining a READ lock all updates are prevented, including writes from the thread obtaining it. WRITE locks gives exclusive access to the issuing thread.
However what I want is to give read and write priveleges to one thread and read priveleges to all other threads, and I can't figure out how to obtain this effect with lock tables... Is it even possibel?




View Complete Forum Thread with Replies

Related Forum Messages:
MySql Write Vs Read
Essentially I am faced with a design choice;

have an oft run (modifiable) query run every time any user wants to
run it, comparing criteria againt each and every user in the table and
delviering list OR saving that list (user/user/) so the next time all
that needs to be queried is the existence of a record in the table.

The basic tradeoff; version 1 there are many simultaneous queries of
the user db on complex search criteria; version 2 there are fewer but
their are as many far more simple queries to a much larger table, not
to mention many writes to same to keep the table current.

I know this is pretty vague, but I was wondering if in general there
is an area that mysql excels in vis a vis complex query smaller tables
simple query larger tables.

Question 2 is there anyway to guestiate the search/write times of a
user log in to both query and update? #Records, fields, etc? I'd like
to keep log in to < 10 seconds max.

View Replies !
Write Once Read Many Field
I am designing a database and one of the requirements my client has is that once data is entered into certain fields it cannot, under any circumstances, be changed. Is it possible to create a write once read many (WORM) field in MySQL directly?

View Replies !
Write Vs. Read Performance
I'm guessing this is just as much a file system question as a MySQL question, but I haven't been able to find any information touching this particular subject.
Not considering data sent through network, what would be faster, fetching a row from a database, updating those columns that have been changed, let's say one of five, or simply don't fetch and update all the columns in the row (not including the id of course)?

View Replies !
No Read Or Write Between INSERT And UPDATE
I am using mysql with the InnoDB engine. I wrote a perl script that
first selects something from a table, and then updates a second table
based on the select from the first table. I need to make sure that
there is no read or write to the tables while my script performs the
insert and update.

I looked at

http://dev.mysql.com/doc/refman/4.1/en/lock-tables.html

and it says this:

---------------------------------------------------------
If you are using a storage engine in MySQL that does not support
transactions, you must use LOCK TABLES if you want to ensure that no
other thread comes between a SELECT and an UPDATE. The example shown
here requires LOCK TABLES to execute safely:

LOCK TABLES trans READ, customer WRITE;
SELECT SUM(value) FROM trans WHERE customer_id=some_id;
UPDATE customer
SET total_value=sum_from_previous_statement
WHERE customer_id=some_id;
UNLOCK TABLES;

Without LOCK TABLES, it is possible that another thread might insert a
new row in the trans table between execution of the SELECT and UPDATE
statements.
---------------------------------------------------------

However, I am using InnoDB and it DOES support transaction. So, does
that mean that even if I don't lock my tables, it will still work? If
not, what do I need to do?

View Replies !
Read/write Table Efficiency
I've got a bit of an efficiency question, and just trying to figure out how best to manage this.

For my site HearWhere.com, I have a table which holds artists shows.

When i am refreshing the collection of shows and geocoding the locations, the database response for user queries slows significantly - which is understandable.

One option I'm considering is to have one database which the users connect to for queries, and a second separate database for writing the updates, and then I can just move the updated database to become the live database on a daily basis.

The other option I think is just to have a separate table which I write the updates to, and then just replace the table the users interact with from the table which was updated

Either way I go, at the moment everything would be done on the same sql server - I don't currently have enough traffic to justify multiple servers.

View Replies !
Can Seqouia/c-jdbc Segregate Read & Write DBs ?
I haven't started using Seqouia/C-jdbc but I am probing the ability to
do something like this:

Controller CW has 2 controllers under it - C1 & C2.
C1 is local and has a host HA with X.db's tables t1 & t2.
C2 is remote and has a host HB also with X.db's tables t1 & t2.

Controller CR has 2 controllers under it - C3 & C4.
C3 is local and has a host HC with X.db's tables t1 & t2.
C4 is remote and has a host HD also with X.db's tables t1 & t2.

X.db is MySql type, from experience I've found that MySQL is better off
doing either only writes or only reads. So I want to segregate my read
and write stores. Hence, HA & HB are meant for writing into, while HC &
HD are meant for reading.

Now writes coming to CW should be treated like transactions which land
up on local and remote X.db. These are my WRITE-ONLY-DBs.

Likewise I want reads to goto CR for load balancing with higher
priority to read from HC than HD.

Questions:
(a) Can c-jdbc help in replication of data between HA-HC and HB-HD ?
Which component would help to set this up ? Or do I need to go for
out-of-band MySQL replication ?

(b) Is this configuration optimal for high scalability or availability
? Should I have added contollers horizontally instead of vertically ?

(c) Also, looks like I'd have to write an app to direct writes to CW
and read to CR. Or is there a way to obviate that with the controller
settings itself ?

View Replies !
Obtaining Read/Write Ratio -Replication
I am looking into a replication strategies to improve performance and
redundancy for a MySQL 4.1 database running on
Linux/Apache2/mod_python.

I am curious as to the standard way of obtaining a Read/Write Ratio.

What patterns of usage suit One-Way or Two-Way replication?

In my situation I have a database that intermittent bursts of inserts
through the day, a lot of batched deletes/inserts/updates over night
and fairly constant selects. I'd expect the RW Ratio would fluctuate
dramatically in a 24 hour period.

View Replies !
How To Change Read/write Permission On Mysql Data Base.
I had a total crash and the server guy gave me all my data in a hand basket.. just kidding..

Actually I was given the data all zipped up and the mysql data bases were separate and they were the direct downloads as follows:
wp_comments.MYD
wp_comments.MYI
wp_comments.frm
all data was in this format.
I used SSH and uploaded it to the proper directory on the server and all is well at least as far as visitors seeing all the data.. but when I log into the site I get the following...

WordPress database error: [Table 'wp_options' is read only]
UPDATE wp_options SET option_value = 'O:9:"magpierss":18:{s:6:"parser";i:0;s:12:"current_item";a:0:{}s:5:"it ems";a:10:{i:0;a:12:{s:5:"title";s:13:"WordPress 2.2";s:4:"link";s:54:"http://wordpress.org/development/2007/05/wordpress-22/

I used SSH and tried to change the concerned files to writable and it works fine but the same error is generated.

I can go direct to the data base using myAdmin and cannot edit (write) to any table. It says the data base is read only.

On the same mysql area, I have another data base that was done via the normal way and I can write to it just fine.

I can find nothing to change to make the site writeable.

Any help here would be greatly appreciated..

SSH to the server and changing the files to writable has no effiect..

View Replies !
Mysql Master/Slave Read Write To Database Question
If I setup my database as master/slave and user enters data into the html form. This data is written to the master database. After html form submission user is directed to view.html to view the submitted data. The view.html page does the read from the slave. Would it be safe to assume that the data that user submitted would be written to master and immediately displayed in the view.html by reading slave data base?

View Replies !
Search And Write, Or Write And Recover?
The problem: I need to generate a 'unique string' for each row in a table. I already use auto_increment for system dependencies between tables.

What is the best approach one of these or another?

After generating a candidate 'unique string' the two strategies that came to mind are:

1. to then search the table's column to see if it is already assigned; locking the table for write while searching and writing the new row, or

2. set the column to UNIQUE when defining the table. Just go ahead and write the new row if you get a "non-unique" exception, generate another 'unique string' and try again.

I've tried both on a small XP laptop and get "lock timeout exceptions" rather quickly using #1. But replace those with lots of re-writes when there starts to get "collisions" of 'unique string's.

View Replies !
Locks
I'm designing a system for bank operations registry, the system is required to give to one user a reference number that will be used in the bank's system as a reference. At the end of the bank's process this number will be also used as the key for keeping track of the file that the bank's system outputs. In the meantime, another user has to be able to generate another serial from the tracking system to make another bank operation.

I've thought of two different aproches to solve this:

1) Lock the table with LOCK WRITE so there will be no chance to repeat the numbers.

2) Make an insert and later on, insert the rest of the information to the tables.

Aproach number 1 has one evident problem, while the first user doesn't complete the whole procces, the lock will prevent other users to get a number to start their own proccess.

Aproach number 2 has problems as well, because, if user number 1 doesn't complete the proceess there will be a serial number which doesn't have all the information that it should have.

Is there another solution ?

View Replies !
Help: Detecting Locks?
I'm writing a program (using mysql++) where I want users to be able to
lock a row while they are editing it. My problem is I don't know how
the 2nd user can detect the lock vs it looking like a failed query.

I have innodb_lock_wait_timeout set to 1 second, which works fine, but
mysql returns two errors when I try to update:

ERROR 1205 (HY000): Lock wait timeout exceeded....
ERROR 1064 (42000): You have an error in your SQL syntax....

Unfortunately, as far as I know, I can only get the *last* error from
the query which is 1064 - bad syntax. Since the 1064 overwrites the
1205 error, I can't differentiate the two.

View Replies !
Detecting Locks
I am having a hard time finding any info on this subject, so I was
hoping maybe one of you could give me some pointers.
I am writing an application in Java that uses Connector/J to interface
with a MySQL database with InnoDB tables. When user #1 opens a certain
record set I am locking this record set in share mode. Therefore if user
#2 selects the same record set (and thus placing a lock as well) user
#1 will not be able to update the record set.
Is there a way to detect this, and thus making it possible to inform
user #1 that an update is currently not possible due to another lock?

View Replies !
Table Locks
I have a table with ~1.5 million rows and 200 columns. I am doing a "Delete from" statement to clean out the table, but still keep the table structure.

When I do this I get an error message about exceeding the lock table size.

Can someone explain (in newbie terms) how I can change the lock settings so that I can delete the entire table at once?

View Replies !
Innodb & Locks
My Applications, that uses ADO/VB^ to communicate with a MYSQL db with Innodb tabes need to create row level locks.

I got this working by using the following code ( abridged from main application) .....

View Replies !
Frequent Table Locks
Since we upgraded to MySQL 4.0.13 from 3.23, we have been getting table
corruption often. It happens about twice per week (with about 500
queries per second average). I have even set up a cron to run
mysqlcheck every hour to try to do some damage control. The biggest
problem is that once the table is corrupted, it seems to be locked.
Well, no clients can read from it. Once repaired, just one record is
usually lost for each time the corruption occurs. I am not sure if this
is a MySQL bug or even how to reproduce it.

View Replies !
Show All Locks On A Table
I found a way to do this before, but I didn't write down how I did it, so I don't remember it now. And I've searched http://www.mysql.com/doc/ in vain.

View Replies !
Locks In Non-transactional Tables
I am using the MyISAM engine in my tables
I need to support atomic operations in read and write operations
I have 2 tables that I am interacting with during a block of code that must be atomic:
1) Read from table A
2) Write to table A
3) write to table B

This is done in 3 separate consecutive queries
I tried the following:Code:


LOCK TABLE A READ, A READ WRITE, B WRITE
.. run the 3 queries here, one after the other...
UNLOCK TABLES

View Replies !
Myisam Insert Locks
I created a table purely for writes, for storring log data, which won't be read, updated, or deleted. It may be read, maybe once a month, so the read really isn't important.Basically, all I will have is INSERTs. My question is, when one INSERT query is being processed, can other INSERT queries simultaenously be processed as well? Or is the table locked when 1 insert is occuring?

View Replies !
Questions About Innodb Locks
I am a bit confused about Innodb deadlock and the "SELECT…FOR UPDATE” statement.

1. Here is a deadlock example
1) Create actor table

Code: ....

View Replies !
Website Freezes Due To Locks
I have used this command for database back up

mysqldump -u USER -pPASSWORD --skip-extended-insert --lock tables DATABASE | gzip dump.sql

or

mysqldump -u USER -pPASSWORD --skip-extended-insert DATABASE | gzip dump.sql

But even though i use lock tables or not , my website freezes for that period of time untill backup is finished. Is there anyway that users should be able to use website during backup

View Replies !
CPU Pegged - MySQL Locks
have a dual Quad core processor, 8 gig RAM, SUSE running MySQL 5.0.26.

Randomly, usually during peak times, the MySQL will completely lock up and stop serving queries. Looking at HTOP during the crash we can see 1 out of the 8 processors pegged at 100% and hardly any RAM or other CPU usage going. If we kill 9 then MySQL starts again.

I think one mysql process is locking the database. I don't know if this is a mysql bug or if it's a query locking every db. I'm leaning towards a mysql bug since a query that locks every would have to be an administrator database command.

View Replies !
Table Locks A Process Is Waiting On
I'm having a lock of locking on the MyISAM tables on my forum, and so I'd like to know which tables are responsible for the blocking of the threads, so I can convert those specific tables to Innodb.

View Replies !
Backups Taken By Mysqldump Locks Database
i've made a backup / restore script which first dumps the content of the database
with mysqldump and the copies the backup file to another location.

What i find strange is that after mysqldump is finished with dumping the data and the
copy operation is started, the database does not accept inserts or update. In our Java application (using hibernate) we are informed that tables are locked (even thoug they should not be). when the copy process is finished it works again!

View Replies !
Searching Table Which Is Being Constantly Updated Locks Up.
I'm logging mail to a database, and using php to make queries. The mail is
coming in constantly, so the table is being added to, in batches of up to 30
mails. I have around 600k records.

The queries are properly indexed, i think; i have index on date and domain,
the fields I query on.
Mostly the queries run quite fast, but sometimes the queries take up to two
minutes.

The query is a union of two queries into two different tables.

mysqladmin -proc says the query is in state "sending data" for the whole
time.

Should it be a problem querying on a live table this size?
Any parameters I can tweak and/or monitor?

What if I seperated the data in two tables, one for today being updated
constantly, and the other for the historical data, and todays data being
moved to historical at midnight. Then queries to the historical data can be
stored in the query cache.

View Replies !
Complicated Search Locks Up MySQL On OpenBSD
I have an OpenBSD 3.3 system running MySQL 3.23.55 from the ports
tree. Everything started out at the default settings. This system
holds a large vBulletin 2.2.9 forum database, and that's pretty much
the only application that uses any resources.

Everything works fine, except that when the forum administrators do an
IP search, the database locks up and won't respond to any more queries
until it gives up on that search or is restarted. The actual query
that causes the problem is: Code:

View Replies !
Locks Exceeds The Lock Table Size
I'm trying to insert data into a table from another table and I'm getting this error: The total number of locks exceeds the lock table size, how can I fix this.

View Replies !
Cant Write Or Delete
I cant get my php script to insert or delete records into a mysql
table. I can view them all fine but that's about it. I've checked
the user permissions on mysql and have set them all to 'Y' incase that
was the problem but still no joy. Can anyone suggest what the problem
may be? I'm tried the usual RTFM but cant spot the problem

View Replies !
How To Write A Trigger
we have an invoice table with fields ( invoice_id,date, item_id,item_name, price_per_item,quantity,cust_id)

here (item_id ,item_name and price_per_item) are from table item_details.

now i have to write a trigger to track the users who have changed the price_per_item column before insertion in invoice table.

View Replies !
Write A Mysql Db Onto A Cd
how to write the db of a mysql on one system onto a cd so as to copy that db to the mysql on another system.
The 2 systems are not connected to each other.

View Replies !
Write Data To Row With Via C API
I have an app written in C that sends data to text files. The files receive 8 variables and look like this:

May 19 20:42:09 2002
7
Services
3.23
4.34
0
None
2.31

Rather than writing data to a text file, I need that data to go to a MySQL 5.0.41 database row. I've already got the C API working and connecting to the "localhost" database, but now I need to write data with each transaction. Optimally, I'd like to send the data directly to the database row, but there doesn't seem to be an INSERT statement to do that. What's the best method to write the data to the database directly?

View Replies !
Can't Write To File
Using MySQL 4.1.11-max on OS X 10.3. Using command line.
Can't successfully use "INTO OUTFILE". Getting the following:
mysql> select *
-> into outfile '/users/steves/desktop/test.txt'
-> fields terminated by ','
-> from industry;
ERROR 1 (HY000): Can't create/write to file '/users/steves/desktop/test.txt' (Errcode: 13)
At the shell, I get this:
steves2ndmac:~ steves$ perror 13
OS error code 13: Permission denied

Newbie in both Unix shell and MySQL. Can anyone tell me how to set permissions for Unix User mysql?

View Replies !
How To Write Trigger
want to copy the table data from one host to another host

why because its live data . i want to update one host to another host.

ie i have one host 192.168.1.1 (db name is EXample table is live)

i want to copy the live table values into another table which is located in
different host ie(192.168.5.5 db name is Datadummy and table is livedummy).

in triggers is it possible or not?

View Replies !
Cannot Write To Database
The result I am getting is:

request "Could not execute SQL query" SELECT dt FROM webcalendar_events WHERE dt in ('2009-03-13') AND calendar_id=cum_wetheralhalls FOR UPDATE Unknown column 'cum_wetheralhalls' in 'where clause'

The strange thing is that when the calendar_id is a numeric value, it works perfectly. Is there anything that I can do in MySQL to get this to work with text-characters also, or do I have to use numeric values for this?

Is this something in the PHP script that is preventing it from saving to the database?

In case you need to know the table row calendar_id is varchar(30).

View Replies !
Best Way To Write This Query
Query 1: obtains results in boolean mode from products table based on keywords

Query 2: Would like to grab all manufacturers names from manufacturers table based on mf_id in products table to then create a brand filter.

What is the best way to do this in the most efficient query possible.

I was thinking of building a php array from query 1 of mf id's and the putting them in query 2 and separating them using OR operators.

any ideas?

here is the query fyi:

PHP

$sql ="SELECT products_id as prodid,
products_name as name,
manufacturers_id as manufacturers_id,
products_price as price,
products_msrp as msrp,
products_date_added as pda,
products_status as status,
products_sku as sku,
products_weight as weight,
categories_id as cat_id,
"
.boolean_sql_select(
boolean_inclusive_atoms($search_string),
$fulltext_key)." as relevance
"
."FROM $table_name
"
."WHERE
"
.boolean_sql_where($search_string,$fulltext_key)."
"
."HAVING relevance>0
";



if (isset($HTTP_GET_VARS['sort'])) {
if ($_GET['sort']=="brand") {
$sql.="ORDER BY products_name ";
} elseif ($_GET['sort']=="size") {
$sql.="ORDER BY products_weight ";
} elseif ($_GET['sort']=="price_low") {
$sql.="ORDER BY products_price ASC ";
} elseif ($_GET['sort']=="price_high") {
$sql.="ORDER BY products_price DESC ";
} elseif ($_GET['sort']=="fav") {
$sql.="ORDER BY products_name ";
}

} else {
$sql.="ORDER BY relevance DESC
";
}

View Replies !
Help Me Write This Join?
Hi there, been ages since I wrote any sql, and I'm a little stuck but I figure this is easy for you folks. I have this original query:

$posts = $wpdb->get_results("SELECT ID, post_title FROM " . $wpdb->posts . " WHERE post_status='publish' ORDER BY post_date DESC");

And this gives a lists of all posts. However, I want to only grab posts by a certain category now, say category #9. This information is kept in an intersection table called wp_post2cat. The columns in that table are:

rel_id
post_id
category_id

category_id is what I want, and post_id is the key pointing back to the original post. Posts can have multiple categories, but I just want the one listing where it's category 9, which is audio.

So pseudocode would be something like:

SELECT all posts WHERE post_status equals "publish" and the category is equal to audio (9).

View Replies !
How To Write This In MySQL?
I Want to check if a certain value doesnt exist in a ceratain field in
my table as a condition.

"select id from employees inner join
translog on employees.emp_id=translog.empid
inner join outofofficedays on
employees.emp_id=outofofficedays.emp_id inner join holidays
where (here is my question: &#55614;&#57159;-04-02'
doesnt exist in the column translog.vtransdate)
and (&#55614;&#57159;-04-02' not between holidays.H_START and H_END)
order by translog.vTransDate,employees.emp_id limit 1"

View Replies !
How To Write This Select?
I'm having some troubles writing a select. I have the following tables:

theater
-------
- id
- name

movie
-----
- id
- name

showtime
---------
- id
- theater
- movie
- from
- to
- schedule

I would like to list all the theaters with all the available showtimes and movies. I tried to, but i didn't get the result i was expecting. Can somebody help?


View Replies !
How Do I Write This Trigger?
I’ve been searching all over for the answer to this one. If you have the answer, it would help me out a lot!

Using MySQL triggers, I want to sync content between two tables; I have table “user” and table “users”, each have similar columns “last_name” “first_name” “user_id” …etc, and when a row gets written to table “users”, I wanted that record to be replicated and inserted to “user” (with all the same field info).

How do I write this trigger? I know, it’s anti-normalization, but it will really help me out with testing one of our site's authentication.

View Replies !
ERROR 1206 (HY000) At Line 41: "The Total Number Of Locks Exceeds The Lock Table Size"
I'm loading a large file into a table, and I get this error:

"ERROR 1206 (HY000) at line 41: The total number of locks exceeds the lock table size"

I already searched, and the only advice given was to do an explict full-table lock on that table before loading to avoid the row-by-row locks filling up the lock table. Well, I tried that, and it's not helping either.


Here's my log:

View Replies !
C- Program To Write To Myi , Myd File
is it possible to create a myi, myd file for mysql using a C program. I
am using Stata that is written in C API, and I want to write the data
out to MYSQL database. Using ODBC and loading the data in MYSQL from
STATA takes forever. Can anyone please tell me if I can create the myd
files by using the data in memory thru C programming.

View Replies !
Using INSERT To Write To A Directory
I have a problem that I'm not sure if it can be done. I'm trying to
use the MySQL C API to be able to use a normal sql insert statement
that will send the data or file to a directory and NOT the database.
I'm not sure if there is anything out there that will allow this, but
I've searched everywhere, and I have found no solution.

View Replies !
Write Conflict Error
I have a database with access as front end and Mysql as back end. I am
gettting the following 'Write Conflict' Error. when i am on my order
form, This form does has a subform where i enter all the products that
are ordered.

Could any one let me know what could cause this problem. I am the only
one using the database as its still in the build stage Code:

View Replies !
Cant Write Or Delete To Table
I cant get my php script to insert or delete records into a mysql
table. I can view them all fine but that's about it. I've checked
the user permissions on mysql and have set them all to 'Y' incase that
was the problem but still no joy. Can anyone suggest what the problem
may be? I'm tried the usual RTFM but cant spot the problem

View Replies !
How To Write Stored Procedures?
1. i want to write a stored procedure using mysql 5.0.45 version.

2. when i tried with the following code ,i am unable to write ...

View Replies !
How To Write Group By Query
i create table item-info. i want to view my data in the following way. i write query use group by but i want name show only one time no repeatation name next line.

item-info table:

id name item price

1 A XX 15

2 B XX 16

3 A YY 17

4 C YY 20

5 B ZZ 50

6 A ZZ 40

View my data in the following way:

name item price

A XX 15

YY 17

ZZ 40

B XX 16

ZZ 50

C ZZ 20

View Replies !
Select .. Into Outfile Write
global scope:
trying to execute on a schedule a .sql file which writes out
a .csv file.

windows(dont ask)/mysql

in the batch file i have

mysql -u myUser --password=somePass < myFile.sql

the sql query in the file

Code:

use mydb;
select field1,field2,field3
union
select `actField1`,`actField2`,`actField3` into outfile 'F:folder est.csv'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' FROM `detailsTable`;

View Replies !
Create/write To The File
I am working on Solaris and seem to get the following error
Cant create/write to the file '/home/dslab456/temp/tempoutput.lst'
As in windows i cannot specify which drive it is or so ? could anyone help me out with this ?

SELECT * INTO OUTFILE '/home/dslab456/temp/tempoutput.lst'
FROM stocklist_vokus s,p_tmpr p
WHERE s.STOCKLIST =p.stocklist_value
ORDER BY p.rid



Edited 1 time(s). Last edit at 02/12/2007 05:38AM by summer queen.

View Replies !

Copyright 2005-08 www.BigResource.com, All rights reserved