How to update gigabytes of data in cratedb - cratedb

Hello stack overflow I have an update query in cratedb. I want to know how I can modify my query so I can update around 8 gigabytes of data.
`UPDATE scp.TransactionsV2
SET "itemPrices" = extract_item_prices("serializedTransaction");`

Related

Why some rows can be inserted into and some cannot? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
When I use the Cashier table or some other tables that have small amounts of records the process proceeds and table is inserted into the external database. But when I change the cashier into the transaction database (400k+ records), Visual Studio reports an error near "Transaction" Help would be appreciated thanks.
Cashier Database (working)
Dim query As String = "select * into MyDatabase2.dbo.Cashier from bos_primary_db.dbo.Cashier"
Transaction Database (not working)
Dim query As String = "select * into MyDatabase2.dbo.Transaction from bos_primary_db.dbo.Transaction"
This is the error message:
Incorrect syntax near the keyword 'Transaction'
this is probably because Transaction is a reserved word in SQL.
Depending on your RDBMS (that you didn't specify), there are ways to "escape" it:
for Sql Server, you should wrap reserved words in square brackets:
select * into MyDatabase2.dbo.[Transaction] from bos_primary_db.dbo.[Transaction]
For MySql you should use an apostrophe:
select * into MyDatabase2.dbo.`Transaction` from bos_primary_db.dbo.`Transaction`
For Oracle you should use double quotes:
select * into MyDatabase2.dbo."Transaction" from bos_primary_db.dbo."Transaction"
Note: You should always try to avoid using reserved words. This link describes my favorite way of do it.

Fastest Way to Update table in SQL Server

I have a Vb.net application that is updating a table in a SQL Server database very frequently. The table has 143 columns and about 10,000 rows. The same procedure is required to update the table for several different modules so the data updated is different all the time, sometimes it could be just a few cells in a few rows other times it may be several hundred rows and several columns.
At times it's taking 15 to 30 seconds to update the information. That seams really long given that the table can be totally re-written with a bulk import in a second or 2 (I realise that that is beside the point). The database is set to simple recovery, the table has only one index. I have tried playing around with the update batch size to no noticeable improvement.
I'm using the below code to do the update. Is there anything that I can do to improve the speed?
Dim oMainQueryR As String
If DBSelectionsDS.HasChanges Then
Try
oMainQueryR = "SELECT * FROM DBSelections"
Using connection As New SqlConnection(RacingConStr)
Using oDataSQL As New SqlDataAdapter(oMainQueryR, connection)
oDataSQL.UpdateBatchSize = 100
Using cbT As SqlCommandBuilder = New SqlCommandBuilder(oDataSQL)
connection.Open()
oDataSQL.Update(DBSelectionsDS, "DBSelectionsDetails")
connection.Close()
End Using
End Using
End Using
DBSelectionsDS.Tables("DBSelectionsDetails").AcceptChanges()
Catch ex As Exception
ErrMess = "ERROR - occured " & ex.ToString
Call WriteError()
Call ViewError()
End Try
End If
I would be willing to bet the bottleneck lies in two places:
First, You are selecting everything from your table every time you need to run the update. This will take longer and longer as your table grows in size. The SqlCommandBuilder only needs a schema to work with so change your query string to this:
oMainQueryR = "SELECT * FROM DBSelections WHERE 0 = 1"
This will return only the schema and column names for the table but no rows, your DataSet contains all the data information the CommandBuilder needs to perform the update. If you are curious why this works, consider that 0 will never equal 1, so SQL says there are never any rows where 0 = 1, and just returns the schema instead.
Second, the UpdateBatchSize is limiting the batch size of the update.
Consider having 200 rows of changed data in your DataSet. You
will then have to take 2 trips to the database to finish the update.
Setting UpdateBatchSize = 0 will remove this limit, also you can
just remove the line as the default is 0.
Otherwise your bottleneck could be caused by another transaction locking the DBSelections table. Ensure that if you are running any queries against that table while the update is happening, you will either want to use the with (nolock) statement, or ensure that your update is the only transaction occurring at the time.

Error message from simple SELECT statement with practice database [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 8 years ago.
Improve this question
I use the AdventureWorks practice database attached to SQL Server 2012.
A simple statement like:
SELECT * FROM HumanResources.Shift;
gives me this error:
Msg 208, Level 16, State 1, Line 1
Invalid object name 'AdventureWorks2012'.
I also tried:
USE master
GO
SELECT * FROM HumanResources.Shift;
Received same error message. Any idea to why this is happening?
Is AdventureWorks2012 the name of a database or a table?
USE <database name>
means use the specified database to run the query against.
SELECT * FROM <table name>
means select all the rows from the specified table.
--Edit because of change in question--
You don't want to use Master, you want to use the name of your DB. Next, using the object explorer, I would make sure the table actually exists in the Database you created.

How to copy data from SQL query analyzer results

I am inserting stack trace of exception into table.But When I execute select query for that table from sql query analyzer then I dont see complete stack trace in it.
Here is the code..
DataAccess.ExecuteNonQuery(
conn,
"usp_insert_error_detail",
iproductType,
"error",
ex.Message.ToString(),
ex.StackTrace.ToString());
Given that you said the data type for the stack trace is NVARCHAR(200), this is likely not sufficient. You need to make it much bigger, since stack traces can easily exceed 200 characters. You could make it NVARCHAR(MAX), which indicates that the maximum storage size is 2^31-1 bytes. The storage size, in bytes, is two times the number of characters entered + 2 bytes.
Thanks to JSR for the correction, I didn't realize varchar(max) was introduced in SQL 2005.

Recover Updated Data - SQL Server 2005 [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I have an issue that, while using sql server 2005 i have executed update query without where clause (by mistake) and all the original values of the column get lost.
How can I get old values??
Any suggestion/tips/solution is welcome and will be highly appreciated.
Hi AngelIII,
SQL server keeps log for every transation.So you can recover your modified data from the log as well without backup.
Select [PAGE ID],[Slot ID],[AllocUnitId],[Transaction ID] ,[RowLog Contents 0]
, [RowLog Contents 1],[RowLog Contents 3],[RowLog Contents 4] ,[Log Record]
FROM sys.fn_dblog(NULL, NULL)
WHERE AllocUnitId IN
(Select [Allocation_unit_id] from sys.allocation_units allocunits
INNER JOIN sys.partitions partitions ON (allocunits.type IN (1, 3)
AND partitions.hobt_id = allocunits.container_id)
OR (allocunits.type = 2 AND partitions.partition_id = allocunits.container_id)
Where object_id=object_ID('' + 'dbo.student' + ''))
AND Operation in ('LOP_MODIFY_ROW','LOP_MODIFY_COLUMNS')
And [Context] IN ('LCX_HEAP','LCX_CLUSTERED')
Here is the artcile, that explains step by step, how to do it. http://raresql.com/2012/02/01/how-to-recover-modified-records-from-sql-server-part-1/
Restore a backup taken before the update
Restore transaction logs to a point in time before the update
Restore a copy of the table you made before the update
Rollback the transaction that contains the update
It's difficult to offer a specific solution not knowing what precautions you have taken. These may not solve your problem, but may prevent this from happening in the future.
DON'T MESS AROUND WITH SQL THAT ALTERS PRODUCTION DATA UNTIL YOU HAVE ANSWERED THIS QUESTION.