我已经为Amazon Aurora数据库编写了一个查询,以在我的接口CrudRepositoryExtended中删除一些对象,但是当我执行该查询时,它将引发异常!
@Transactional
@Query("delete from HotelPrice hp where hp.updateDate < ?1 ")
void deletePriceOlderThan (Date date);
Run Code Online (Sandbox Code Playgroud)
异常跟踪跟踪:
Caused by: java.lang.IllegalStateException: org.hibernate.hql.internal.QueryExecutionRequestException: Not supported for DML operations [delete from com.gamesa.backend.persistence.domain.backend.HotelPrice hp where hp.updateDate < ?1 ]
at org.hibernate.jpa.internal.QueryImpl.getSingleResult(QueryImpl.java:554)
at org.springframework.data.jpa.repository.query.JpaQueryExecution$SingleEntityExecution.doExecute(JpaQueryExecution.java:208)
at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:87)
at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:116)
at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:106)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:499)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:477)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:56)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
... 35 common frames omitted
Run Code Online (Sandbox Code Playgroud) 我有RDS与Aurora MySQL 5.6.10a.
default_storage_engine设置为InnoDB且无法修改 ( Modifiable = false)。
当我运行命令时
SHOW ENGINES
Run Code Online (Sandbox Code Playgroud)
我收到:
+----------+---------+-------------------------+--------------+------+------------+
| Engine | Support | Comment | Transactions | XA | Savepoints |
+----------+---------+-------------------------+--------------+------+------------+
| 'MyISAM' | 'YES' | 'MyISAM storage engine' | 'NO' | 'NO' | 'NO' |
+----------+---------+-------------------------+--------------+------+------------+
Run Code Online (Sandbox Code Playgroud)
创建带有MyISAM搜索引擎的表。
当我尝试使用命令创建表时:
CREATE TABLE `myTable` (
`myTableId` int(11) NOT NULL AUTO_INCREMENT,
`latLong` point NOT NULL,
`createdAt` …Run Code Online (Sandbox Code Playgroud) 我正在建立一个房地产网站,其中包含房产列表、一些搜索过滤器和一个带有自动完成功能的地址字段。它工作正常,但自动完成的性能非常慢。几乎需要一秒钟才能得到回应。考虑到所有服务都在我所在的地区,我认为这很慢。
我即兴进行了一种“模糊”搜索,我在其中拆分了源字符串(例如,如果用户搜索“Jumeirah, Rimal”变为 [“jumeirah”, “rimal”])并尝试匹配某个位置的完整“路径”(一个像 locationID/city/community/sub-community/tower 这样的字符串,在这个例子中是“are.1.50/Dubai/Jumeirah Beach Residence/Rimal”)到分割字符串的每个部分。表达式变成这样:
contains(#path, :fullString) OR
(contains(#path, :stringOne) AND contains(#path, :stringTwo) AND ... )
Run Code Online (Sandbox Code Playgroud)
重要的是,因为我需要使用“包含”运算符,所以我不能用 KeyExpression 有效地完成它,我需要使用较慢的 FilterExpression 进行完整扫描。我只有 7,500 个位置可供搜索,而且性能已经很差了。
这让我思考是否应该使用像 Aurora 这样的基于 SQL 的数据库。AFAIK SQL 可以非常高效地执行复杂的查询。
我还将研究 AWS 的弹性搜索解决方案。
你怎么认为?
amazon-web-services amazon-dynamodb amazon-aurora dynamodb-queries
使用云信息模板创建Amazon RDS Master并读取副本群集.