Atomic Increment without use of transactions

M

Mike

Guest
Mike Asks: Atomic Increment without use of transactions
I'm trying to find a way to have atomic increment without transaction usage. I have the following table

Code:
CREATE TABLE [dbo].[DocumentCategoryInternalId]
(
    [Category] [nvarchar](450) NOT NULL,
    [Id] [bigint] NOT NULL,

    CONSTRAINT [PK_DocumentCategoryInternalId] 
        PRIMARY KEY CLUSTERED ([Category] ASC)
                WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, 
                      IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, 
                      ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO

This table holds a counter per document category (PK/FK relations with Category table is omitted).

Application code needs to get the next value for every document created in a category (like in sql sequences. Not related to the question, but I'm considering change to use sequences to achieve this).

Existing code that currently implements atomic increment is the following

Code:
UPDATE [DocumentCategoryInternalId] 
SET [Id] = [Id] + 1 
OUTPUT INSERTED.* 
WHERE Category = 'Category 1'

My understanding is that this is not correct. P1 & P2 processes can read the same value, so after both updates Id will remain as N + 1 (where N is initial value both P1 & P2 read). Whereas expected result should be N + 2.

In an attempt to guarantee atomic increment I came up with the following but it looks cumbersome

Code:
DECLARE @initialId BIGINT

INCREMENT_ID:
    SELECT @initialId = Id
    FROM [DocumentCategoryInternalId]
    WHERE Category = 'Category 1'   

    UPDATE [DocumentCategoryInternalId] 
    SET [Id] = [Id] + 1 
    OUTPUT INSERTED.* 
    WHERE Category = 'Category 1' and Id = @initialId

IF(@@ROWCOUNT = 0)
BEGIN
    GOTO INCREMENT_ID
END

So my question is, is there any way (better than what I have) to implement atomic increments without using transactions.

SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your thoughts here to help others.
 

Unreplied Threads

Vector fields $X$ and $Y$ commute on a closed set $K$. Do there exist commuting $\tilde X,\tilde Y$ with $\tilde X=X$ and $\tilde Y=Y$ on $K$?

Blake Asks: Vector fields $X$ and $Y$ commute on a closed set $K$. Do there exist commuting $\tilde X,\tilde Y$ with $\tilde X=X$ and $\tilde Y=Y$ on $K$?
I have a nice research idea whose proof hinges on the following question

Suppose $X_p$ and $Y_p$ are vector fields in $\mathbb{R}^3$ with $[X,Y]_p=0$ for all $p$ in some closed set $K\subset\mathbb{R}^3$. For each point in $p\in K$, does there a neighborhood $U$ of $p$ and a two dimensional foliation $\mathcal{F}$ on $U$ with the property that $T_qL_q=\text{span}(X_q,Y_q)$ for each $q\in U\cap K$? Here $L_q$ denotes the leaf of $\mathcal{F}$ through $q$.

At a first glance, I thought this was probably true: after all, if such a foliation existed, then the vector fields must commute on $K$. But the more I try and prove it, the more I am having second thoughts on whether this is true.

My naive attempt at a proof involves mimicking the proof of the Frobenius theorem; i.e. my candidate for the foliation would be the coordinate change $$ (t_1,t_2,t_3)\mapsto\theta_{t_1}\circ\psi_{t_2}(0,0,t_3), $$ where $\theta_t$ and $\psi_t$ denote the flows of $X$ and $Y$ respectively, but the details get a little hairy when the vector fields don't always commute.

I imagine that this has been studied before, so I was hoping someone would know of a reference that studies this question. If this is not true in general, what additional hypotheses are required?

Any help would be greatly appreciated. Thanks in advance.

SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your thoughts here to help others.

$\lim_\limits{x \to 0}|x| \cdot \cos{\frac{x-5}{|x^2-x|}}$ simple calculation not actual proof required

Adamrk Asks: $\lim_\limits{x \to 0}|x| \cdot \cos{\frac{x-5}{|x^2-x|}}$ simple calculation not actual proof required
calculate $\lim_\limits{x \to 0}|x| \cdot \cos{\frac{x-5}{|x^2-x|}}$


I am trying to figure why it is is equal to zero , in a simple way no need for a proof just limit properties or a use heine series theorem

$\cos{\frac{x-5}{|x^2-x|}}$ does not exist because it will be $\lim_\limits{x \to 0}\cos{\frac{x-5}{|x^2-x|}}=\cos{\infty}$ but $\lim_\limits{x \to 0}|x|=0$

I believe it is equal to zero because "zero limit $\cdot$ bounded limit=0"

or because $\lim _\limits{n \to \infty} |a_n|=0 \iff \lim _\limits{n \to \infty} a_n=0 $

since then we will get $\lim_\limits{x \to 0}|x| \cdot |\cos{\frac{x-5}{|x^2-x|}}|= \lim_\limits{x \to 0}|x| \cdot 1 =0$

but I am not sure if I can use that here as $x \to 0$ and not $\infty$

thanks for any tips and help

SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your thoughts here to help others.

Bott Tu local constant presheaf

math3341 Asks: Bott Tu local constant presheaf
I´m reading Bott Tu Differential forms in algebraic topology and I have a question. In the page 169 we wnat calculate cohomology of a fiber bundle $\pi:E\to M$ with fiber $F$, and we define the presheaf $\mathscr{H}^q:=H^q(\pi^{-1}(U))$ en $M$. Then the book says that for a good cover $\mathfrak{U}$, $\mathscr{H}^q$ is a locally constant presheaf on $\mathfrak{U}$ with group $H^q(F)$. Anyone can explain me this? Please.

In the next page (170), the book takes the trivial bundle $M\times F$ and says that $\mathscr{H}^q(F)$ is constant presheaf. Why?

SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your thoughts here to help others.

Curious Function Composition

godlification Asks: Curious Function Composition
Find all functions $f$ such that $f^5(n)=2022n$.

SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your thoughts here to help others.

What is this separation property of locales called

Jonas Frey Asks: What is this separation property of locales called
Trying to come up with a point-free formulation of the $T_1$ axiom I thought of the following condition on a frame/locale $L$:

$$\forall U \in L \, . \, U \wedge \bigwedge \{ V \in L : U \vee V = \top \} = \bot$$

It turns out that this condition is weaker than $T_1$ for spatial locales since it holds eg for $T_1$ spaces with non-$T_1$ sobrification like $\mathbb N$ with the cofinite topology, but at least it seems to exclude non-trivial Alexandroff locales.

Does anybody know what this condition is called?

SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your thoughts here to help others.

Does Ricci flat with $b_1=0$ imply fundamental group is finite?

How Asks: Does Ricci flat with $b_1=0$ imply fundamental group is finite?
Let $(M,g)$ be a Riemannian manifold with Ricci curvature vanishes, that is $\mathrm{Ric}(g)=0$. Now I want to show some topological result about $M$.

Myers' theorem implies if $\mathrm{Ric}(g)>0$, then $\pi_1(M)$ is finite. It's clear that this is false for $\mathrm{Ric}(g)=0$, for example we can consider $n$-torus. But I wonder if we require $b_1(M)=0$, that is first Betti number of $M$ vanishes, does we have $\pi_1(M)$ is finite?

SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your thoughts here to help others.

In many tv shows, why do characters "turn g*y" rather than be bisexual?

  • Crafter
  • Social
  • Replies: 0
Crafter Asks: In many tv shows, why do characters "turn g*y" rather than be bisexual?
In many tv shows, there is this one trope that, while cam vary, boils down to this:

A character who once thought they were straight, ends up having feelings for someone of the same gender and/or biological sex. From there, the character then realizes they are g*y. However, this person, with previous partners of the opposite gender, had truly meaningful relationships.

Of course, if you are guessing right, the described character above is bisexual. However, in many tv shows, it is portrayed as "turning g*y", despite the fact that they had legit feelings in their heterosexual relationships. My question is: Why do TV shows do this trope, resulting in bi-erasure, than just saying that said character is bisexual?

SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your thoughts here to help others.