MYSQL TRANSACTION alternative?

Asked
Active3 hr before
Viewed126 times

5 Answers

transactionalternativemysql
90%

What is being done in the 'other' table. Depending on whether you need external computation you can do this all via a single query with sub selects. If the computation is based on data in the two tables you can likely write it that way. SQL doesn't require iteration in most cases, but acts directly on each cross-product tuple of the joined relations.,(Alternatively, you could switch to a DB that support stored procedures and run it that way.),Can someone suggest, how can I proceed with some other alternative to TRANSACTION OR LOCK OR some other table structure so that I can process each ROW in mytable faster / concurrently by running same PHP script multiple times together ? , Yes @bestprogrammerintheworld I need PHP for processing the data. You can please consider this as extension to my previously asked question at stackoverflow.com/questions/23539380/… – jahajee.com Mar 7 '15 at 7:30

InnoDB by default has REPEATABLE READ isolation level.

SELECT @ @GLOBAL.tx_isolation, @ @tx_isolation;
SET SESSION tx_isolation = 'READ-UNCOMMITTED';
load more v
88%

You need to perform transactional processing, but your MySQL server doesn’t support transactions. ,Some transactional operations are amenable to workarounds such as explicit table locking. In certain cases, you may not actually even need a transaction; by rewriting your queries, you can eliminate the need for a transaction entirely. ,Applications sometimes use transactions when they’re not really necessary. You may be able to eliminate the need for a transaction by rewriting statements. This may even result in a faster application. ,Your server may not support transactions at all. (It may be too old or not configured with the appropriate table handlers, as discussed in Recipe 15.2). In this case, you have no choice but to use some kind of workaround for transactions. One strategy that can be helpful in some situations is to use explicit table locking to prevent concurrency problems.

If your server doesn’t have transactional capabilities but you need to execute a group of queries without interference by other clients, you can do so by using LOCK TABLE and UNLOCK TABLE:[58]

LOCK

If your server doesn’t have transactional capabilities but you need to execute a group of queries without interference by other clients, you can do so by using LOCK TABLE and UNLOCK TABLE:[58]

TABLE

If your server doesn’t have transactional capabilities but you need to execute a group of queries without interference by other clients, you can do so by using LOCK TABLE and UNLOCK TABLE:[58]

UNLOCK

If your server doesn’t have transactional capabilities but you need to execute a group of queries without interference by other clients, you can do so by using LOCK TABLE and UNLOCK TABLE:[58]

TABLE
load more v
72%

Federated: Offers the ability to link separate MySQL servers to create one logical database from many physical servers. Very good for distributed or data mart environments. , You are not restricted to using the same storage engine for an entire server or schema. You can specify the storage engine for any table. For example, an application might use mostly InnoDB tables, with one CSV table for exporting data to a spreadsheet and a few MEMORY tables for temporary workspaces. , Storage engines are MySQL components that handle the SQL operations for different table types. InnoDB is the default and most general-purpose storage engine, and Oracle recommends using it for tables except for specialized use cases. (The CREATE TABLE statement in MySQL 8.0 creates InnoDB tables by default.) , NDB (also known as NDBCLUSTER): This clustered database engine is particularly suited for applications that require the highest possible degree of uptime and availability.

To determine which storage engines your server supports, use the SHOW ENGINES statement. The value in the Support column indicates whether an engine can be used. A value of YES, NO, or DEFAULT indicates that an engine is available, not available, or available and currently set as the default storage engine.

mysql > SHOW ENGINES\ G **
   ** ** ** ** ** ** ** ** ** ** ** ** * 1. row ** ** ** ** ** ** ** ** ** ** ** ** ** *
   Engine: PERFORMANCE_SCHEMA
Support: YES
Comment: Performance Schema
Transactions: NO
XA: NO
Savepoints: NO **
   ** ** ** ** ** ** ** ** ** ** ** ** * 2. row ** ** ** ** ** ** ** ** ** ** ** ** ** *
   Engine: InnoDB
Support: DEFAULT
Comment: Supports transactions, row - level locking, and foreign keys
Transactions: YES
XA: YES
Savepoints: YES **
   ** ** ** ** ** ** ** ** ** ** ** ** * 3. row ** ** ** ** ** ** ** ** ** ** ** ** ** *
   Engine: MRG_MYISAM
Support: YES
Comment: Collection of identical MyISAM tables
Transactions: NO
XA: NO
Savepoints: NO **
   ** ** ** ** ** ** ** ** ** ** ** ** * 4. row ** ** ** ** ** ** ** ** ** ** ** ** ** *
   Engine: BLACKHOLE
Support: YES
Comment: /dev/null
storage engine(anything you write to it disappears)
Transactions: NO
XA: NO
Savepoints: NO **
   ** ** ** ** ** ** ** ** ** ** ** ** * 5. row ** ** ** ** ** ** ** ** ** ** ** ** ** *
   Engine: MyISAM
Support: YES
Comment: MyISAM storage engine
Transactions: NO
XA: NO
Savepoints: NO
   ...
65%

By default, every SQL statement runs within it’s own transaction. Switching off autocommit cancels this action so all subsequent SQL updates form part of a single transaction.,Alternatively, you can use:,PHP offers a few other alternatives when starting a transaction. If you’re using the PDO library, you can execute the beginTransaction() method. For mysqli, pass false to the autocommit() method.,Despite being shrouded in mystery, transactions are remarkably simple. The following SQL statement starts a transaction:

In SQL code, this could resolve to:

INSERT INTO customers(name, email, cartid) VALUES('Customer1', 'customer@email.com', 123);
UPDATE cart SET status = 'paid'
WHERE id = 123;
UPDATE product SET stock = stock - 1 WHERE id = 567;
load more v
75%

A perfect alternative to MySQL sharding.,Scales out horizontally., Database ,MySQL can't create secondary indexes.

For the production environment, we suggest choosing a release that has run normally for some time.

TiDB is an on-going technology. Bug fixes and new features are continuously added to new releases. Since our first research, TiDB has matured from version 2.0 to 4.0. When we upgraded from v2.1.x to 3.0.x, we didn't notice the SQL mode change, which resulted in an unexpected impact caused by the ONLY_FULL_GROUP_BY rule. Now, we only choose stable releases and usually don't upgrade our clusters unless we encounter critical bugs or need new features.

ONLY_FULL_GROUP_BY
load more v

Other "transaction-alternative" queries related to "MYSQL TRANSACTION alternative?"