我应该在我刚刚添加到MS SQL Server 2008R2列的索引的Rails模型定义中添加什么?(What should I put in the Rails model definition for the index I just added to a MS SQL Server 2008R2 column?)
我在MS SQL 2008R2服务器上有一个表
orders
orders
的主键为id
orders
有一个名为ordering_date
的列,类型为datetime
我使用一段SQL在服务器上创建了一个名为ordering_date_ndx
的列ordering_date
的索引。 我确实试图使用迁移,但在这个包含2300万条记录的表上运行迁移超时。2个问题:
- 如果有的话,我应该在app / models / order.rb中使用索引。
- 像这样的代码会利用索引的存在并优化SQL查询吗?
list=Orders.find(ordering_date.year == 2006)
谢谢!
I have a table
orders
on an MS SQL 2008R2 server
orders
has a primary key ofid
orders
has a column calledordering_date
that is typedatetime
I created an index of columnordering_date
calledordering_date_ndx
on the server using a snippet of SQL. I did try to use a migration, but running the migration timed-out on this table of 23 million records.2 Questions:
- What, if anything, should I put in app/models/order.rb to make use of the index.
- Will code like this make use of the presence of the index and optimize the SQL query?
list=Orders.find(ordering_date.year == 2006)
Thanks!
原文:https://stackoverflow.com/questions/9346955
最满意答案
将点定义为静态,否则touchBegan点将失去其值。 之所以发生这种情况,是因为设置每个点的值发生在不同的方法调用中,并且每个方法调用都会重新定义开头的点。
static CGPoint touchBegan; static CGPoint pointEnd;
Define the points as static, otherwise the touchBegan point will lose its value. It happens because setting the values of each point occurs in different method calls and with each one, you redefine the points at the beginning.
static CGPoint touchBegan; static CGPoint pointEnd;
相关问答
更多-
您可以使用MotionEvent的历史性内容。 基于API Doc的例子,你可以做这样的事情(为了简单起见,我的例子不涉及多点触控): 在ACTION_MOVE和ACTION_UP上执行此操作,其中startX , startY将是最后一个已知坐标,例如来自上一次ACTION_DOWN事件。 float getDistance(float startX, float startY, MotionEvent ev) { float distanceSum = 0; final int hist ...
-
在旋转,平移和缩放时,CGAffineTransform是一个方便的工具。 要确保正确旋转点,必须将其平移到原点,旋转它,然后将其平移。 要完成转换,以下内容应该可以解决问题: CGPoint pointToRotate = CGPointMake(30, 30); float angleInRadians = DEGREES_TO_RADIANS(90); CGPoint distanceFromOrigin = CGPointMake(0 - pointToRotate.x, 0 - pointToRo ...
-
将CGPoint沿着某个标题移动一定距离... iphone(moving CGPoint a certain distance along a certain heading…iphone)[2022-10-24]
如果p是你的点,D是距离,θ是从X轴的航向角, p new .x = p old .x + D * cos(θ) p new .y = p old .y + D * sin(θ) 但是,不是存储距离和角度,而是通常使用向量 (不需要sin / cos)来完成 If p is your point, D is the distance, and θ is the heading-angle from the X-axis, pnew.x = pold.x + D * cos(θ) pnew.y = pold. ... -
SpriteKit手势问题(SpriteKit Gesture Issue)[2023-09-02]
为什么要将精灵移动到self + 115的位置,而不是mageNodeOne's当前位置mageNodeOne's 。 例: CGPointMake(self.position.x + 115, self.position.y) 应该 CGPointMake(mageNodeOne.position.x + 115, mageNodeOne.position.y) Why are you moving the sprite to the location of self + 115 as oppos ... -
大多数三角函数需要弧度,而不是度。 另外,正如@Putz1103指出的那样,您可以使用运动的UITouch的delta x和delta y ,而不是根据中心点的运动计算两端的新位置。 Most trigonometry functions need radians, not degrees. Also, as @Putz1103 pointed out, you can probably use the delta x and delta y of the UITouch of the movement i ...
-
Objective C比较两个CGPoint以查看它们是否接近?(Objective C compare two CGPoint to see if they are close?)[2024-02-12]
为了估计两个CGPoint之间的距离,可以使用简单的毕达哥拉斯公式: CGFloat dX = (p2.x - p1.x); CGFloat dY = (p2.y - p1.y); CGFloat distance = sqrt((dX * dX) + (dY * dY)); To estimate the distance between two CGPoints, you can make use of simple Pythagorean formula: CGFloat dX = (p2.x - ... -
iPhone - CGPoint距离(以像素为单位)和屏幕分辨率(iPhone - CGPoint distance in pixels and screen resolution)[2022-06-05]
我相信test> = 10.0没有考虑屏幕分辨率。 Apple使用“点”代替像素来完成大部分绘图算法 - 与正常显示相比,代码不必更改视网膜显示。 如果你想画一个只有10.0像素宽的东西,你需要考虑屏幕分辨率; 但是,如果你这样做,你将不得不编写支持视网膜显示和正常显示的方法。 I believe that test >= 10.0 does not take into account the screen resolution. Apple does most of their drawing arith ... -
将点定义为静态,否则touchBegan点将失去其值。 之所以发生这种情况,是因为设置每个点的值发生在不同的方法调用中,并且每个方法调用都会重新定义开头的点。 static CGPoint touchBegan; static CGPoint pointEnd; Define the points as static, otherwise the touchBegan point will lose its value. It happens because setting the values of e ...
-
在CGPoint之后删除*。 Remove the * after CGPoint.
-
我发现了问题! 这只是一个括号的问题: double cosa = ((u.x * v.x) + (u.y * v.y)) / (sqrt((u.x * u.x) + (u.y * u.y)) * sqrt((v.x * v.x) + (v.y * v.y))); 我不明白为什么? 因为括号不是乘法所必需的...... I found the problem ! It just a probleme of parenthesis : double cosa = ((u.x * v.x) + (u.y * ...